Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Unable to set dimension via API

Posted on by 2
Hi, I'm trying to create a sales invoice within Business Central via Power Automate and I'm having trouble setting a dimension on the invoice line.
 
I am successfully creating the sales invoice, then creating a line within the invoice.  Then, when I try to set a dimension on the line I've created, it gives the following error:  /You must get to the parent first to create a dimension set line/.
 
I've tried several different sets of parameters, but they all give the same error.  Here's my most recent try using the Create Record action:
 
The Parent Id is the ID of the invoice line and the Value Id is the ID of the dimension value.  I've also tried setting it using the Value Code and including the Code.  CREATE dimensionSetLines - Business Central | Microsoft Learn doesn't seem to give the example I need in Power Automate.
 
Can anyone guide me on what parameters I need to be specifying to get it to work?  Thanks
Categories:
  • Verified answer
    ajkauffmann Profile Picture
    ajkauffmann 117 on at
    Unable to set dimension via API
    There is a difference between Power Automate and Postman. In Power Automate, the URL becomes this:
     
    POST /api/v2.0/dimensionSetLines
     
    while in Postman the URL is this:
     
    POST /api/v2.0/salesOrders(id)/dimensionSetLines
     
    With the URL in Postman, there is a filter applied to dimensionSetLines from the salesOrders API page. That's because dimensonSetLines is a subpage of salesOrder. The Business Central connector in Power Automate doesn't support this. Instead, it calls directly dimensionSetLines, without any filter. A filter can't be specified, if you try that, then the BC connector will simply fail.
     
    It's impossible to achieve this from Power Automate with the standard BC connector. Even a deep insert (lines + dimensions) is failing. The only option would be to create a custom API or use the standard HTTP connector.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,110 Super User 2024 Season 2 on at
    Unable to set dimension via API
    Update with a reply from my friend:
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,110 Super User 2024 Season 2 on at
    Unable to set dimension via API
    Hi, as far as I know, this is a problem that has always existed. I just tested it and it doesn't seem to be resolved.
     
    If you click Show raw inputs you can find that the parent type has no value, but this value is read-only. I think this is causing the problem.
     
    PS: There are no problems in PostMan.
     
    Additionally, if you insist on using Power Automate, consider the following method.
    Using OAuth 2.0 to connect Business Central APIs and Web Services in Power Automate – OAuth in HTTP action
     
    Hope this helps.
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,963 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans