cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KyleH
Frequent Visitor

Custom connector for Business Central tests successfully but still can't access data in Powerapps

I finished building a custom connector (named JobJournal) to GET access to tables not exposed by the native Business Central connector, per Microsoft documentation. When testing, I receive a proper 200 response including the expected JSON array of all the records in the table. However, when I create a new 'gallery' in my Powerapp, and set the 'data source' to the custom connector, no results are provided. I've also tried manually setting the 'gallery' 'items' to the connector.

 

Here is what the JSON response looks like when testing:

 

 

 

 

{
  "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/5529794d-9ebb-492c-befd-f8fb507c0869/Production/ODataV4/$metadata#Company('WOLF%20Sandbox')/JobJournals",
  "value": [
    {
      "@odata.etag": "W/\"JzQ0O3BRZ2tkQm1PZU5FU2t5T05LUDZQUlZYM3I5bHg0bE9RU2wxMzFXcmQySWM9MTswMDsn\"",
      "Journal_Template_Name": "JOB",
      "Journal_Batch_Name": "DEFAULT",
      "Line_No": 20000,
      "Line_Type": " ",
      "Posting_Date": "2021-06-30",
      "Document_Date": "2021-06-30",
      "Document_No": "1",
      "External_Document_No": "",
      "Job_No": "J00001",
      "Job_Task_No": "010.00",
      "Type": "Resource",
      "Price_Calculation_Method": "Lowest Price",
      "Cost_Calculation_Method": "Lowest Price",
      "No": "R009",
      "Description": "Administration",
      "Job_Planning_Line_No": 0,
      "Gen_Bus_Posting_Group": "",
      "Gen_Prod_Posting_Group": "LABOR",
      "Variant_Code": "",
      "Location_Code": "",
      "Bin_Code": "",
      "Work_Type_Code": "",
      "Currency_Code": "",
      "Unit_of_Measure_Code": "HR",
      "Quantity": 1,
      "Remaining_Qty": 0,
      "Direct_Unit_Cost_LCY": 32,
      "Unit_Cost": 41.6,
      "Unit_Cost_LCY": 41.6,
      "Total_Cost": 41.6,
      "Total_Cost_LCY": 41.6,
      "Unit_Price": 0,
      "Unit_Price_LCY": 0,
      "Line_Amount": 0,
      "Line_Amount_LCY": 0,
      "Line_Discount_Amount": 0,
      "Line_Discount_Percent": 0,
      "Total_Price": 0,
      "Total_Price_LCY": 0,
      "Applies_to_Entry": 0,
      "Applies_from_Entry": 0,
      "Country_Region_Code": "US",
      "Transaction_Type": "",
      "Transport_Method": "",
      "Time_Sheet_No": "",
      "Time_Sheet_Line_No": 0,
      "Time_Sheet_Date": "0001-01-01",
      "Shortcut_Dimension_1_Code": "FINANCE",
      "Shortcut_Dimension_2_Code": "",
      "ShortcutDimCode3": "FINANCE",
      "ShortcutDimCode4": "",
      "ShortcutDimCode5": "",
      "ShortcutDimCode6": "",
      "ShortcutDimCode7": "",
      "ShortcutDimCode8": "",
      "NumberOfJournalRecords": 842,
      "JobDescription": "Model B - Master",
      "AccName": "Administration"
    }
]
}

 

 

 

 

Shouldn't I simply be able to set Gallery > Advanced > Items to 'ForAll(JobJournal.value)'?

 

KyleH_0-1625094860443.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Very helpful but now having a slightly different issue. Intellisense is guiding me to use the function name I created - which makes sense - but returns a '404 resource not found error.' If I append .value, I get the error 'unexpected use of .'

KyleH_0-1625171498283.png

 

Problem is, when testing the custom connector, specifically that function, it works properly, with a 200 status and the expected JSON body.

 

KyleH_1-1625171545930.png

 

View solution in original post

Syndicate_Admin
Administrator
Administrator

You need to use "JobJournal.GetJournal().value". The reason why the value doesnt show up is likely because the response schema is not defined in your connector.

 

You can validate that by looking at the response section of your action in the custom connector. You may need to add one. Do a test run, copy the response payload, and then go back to your action, click on "+Add default response" (see below) and paste the payload. It will generate the schema for you. Save the connector.

SameerCh_0-1625246255501.png

If you click on "default", you should see the fields.

 

Finally, in your app, you will need to remove and add the connector again. This will make sure the new metadata is pulled into your app.

 

View solution in original post

7 REPLIES 7
shyamsu
Power Automate
Power Automate

Hi Kyle

 

Thanks for reaching out. Its more likely an issue with power apps instead of custom connector. To get expert help on PowerApps specific issues, can you please post it under Building Power Apps - Power Platform Community (microsoft.com)

 

Syndicate_Admin
Administrator
Administrator

Let me add quickly:

In Power Apps, you will need to use a formula like:  ConnectorName.OperationName(parameters).Result

 

So, probably like: "JobJournal.OperationName().value" instead of "JobJournal.value".

Try to use the intellisense to guide you to what is possible.

 

Hope this helps

Very helpful but now having a slightly different issue. Intellisense is guiding me to use the function name I created - which makes sense - but returns a '404 resource not found error.' If I append .value, I get the error 'unexpected use of .'

KyleH_0-1625171498283.png

 

Problem is, when testing the custom connector, specifically that function, it works properly, with a 200 status and the expected JSON body.

 

KyleH_1-1625171545930.png

 

View solution in original post

I have found that this was a larger bug with BC custom connectors, and that the companyID, environment and tenantID have to be passed as parameters. That said, I still do not understand how to properly format my request. My connector is titled JobJournal, and the function is GetJournal.

 

 

JobJournal.GetJournal("29794d-9ebb-492c-befd-f8fb507c0869","Production","'WOLF%20Set'")

 

 

This code is no longer 404ing, but now I receive the error 'expected table value'.

 

KyleH_0-1625245475656.png

 

How do I properly format my code?

Syndicate_Admin
Administrator
Administrator

You need to use "JobJournal.GetJournal().value". The reason why the value doesnt show up is likely because the response schema is not defined in your connector.

 

You can validate that by looking at the response section of your action in the custom connector. You may need to add one. Do a test run, copy the response payload, and then go back to your action, click on "+Add default response" (see below) and paste the payload. It will generate the schema for you. Save the connector.

SameerCh_0-1625246255501.png

If you click on "default", you should see the fields.

 

Finally, in your app, you will need to remove and add the connector again. This will make sure the new metadata is pulled into your app.

 

View solution in original post

Do a test run, copy the response payload


Do I need to copy both the head and body json of the test response into the head and body of 'Add default response'? I am trying with both and get the error 'JobJournal.GetJournal failed: {"error": {"code": "RequestDataInvalid","message": "Request data is invalid."}}'

Here is what the custom connector response looks like after updating.

KyleH_0-1625248093683.png

 

Fixed, was a simply string wrapping issue with my quotes, as seen below on the companyId parameter. Thanks a ton!

JobJournal.GetJournal("29794d-9ebb-492c-befd-f8fb507c0869","Production","'WOLF Setup'").value

tenantId: 29794d-9ebb-492c-befd-f8fb507c0869
environmentName: Production
companyId: 'WOLF Set'

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,850)