Hi, Readers.
Today I would like to briefly talk about how to set dimension via standard API and can we do it in Power Automate?
Dimensions are values that categorize entries so you can track and analyze them on documents, such as sales orders. Dimensions can, for example, indicate the area or department an entry came from.
Is it possible to manage this value using the API? Yes, Microsoft has prepared a standard API.
dimensionSetLine resource type: Represents a dimension set line in Business Central.
Methods
Method | Return Type | Description |
---|---|---|
GET dimensionSetLine | dimensionSetLine | Gets a dimension set line object. |
DELETE dimensionSetLine | none | Deletes a dimension set line object. |
POST dimensionSetLine | dimensionSetLine | Creates a dimension set line object. |
PATCH dimensionSetLine | dimensionSetLine | Updates a dimension set line object. |
Navigation
Navigation | Return Type | Description |
---|---|---|
salesInvoice | salesInvoice | Gets the salesinvoice of the dimensionSetLine. |
salesInvoiceLine | salesInvoiceLine | Gets the salesinvoiceline of the dimensionSetLine. |
dimension | dimension | Gets the dimension of the dimensionSetLine. |
customerPayment | customerPayment | Gets the customerpayment of the dimensionSetLine. |
journalLine | journalLine | Gets the journalline of the dimensionSetLine. |
timeRegistrationEntry | timeRegistrationEntry | Gets the timeregistrationentry of the dimensionSetLine. |
generalLedgerEntry | generalLedgerEntry | Gets the generalledgerentry of the dimensionSetLine. |
salesOrder | salesOrder | Gets the salesorder of the dimensionSetLine. |
salesOrderLine | salesOrderLine | Gets the salesorderline of the dimensionSetLine. |
salesQuote | salesQuote | Gets the salesquote of the dimensionSetLine. |
salesQuoteLine | salesQuoteLine | Gets the salesquoteline of the dimensionSetLine. |
salesCreditMemo | salesCreditMemo | Gets the salescreditmemo of the dimensionSetLine. |
salesCreditMemoLine | salesCreditMemoLine | Gets the salescreditmemoline of the dimensionSetLine. |
purchaseInvoice | purchaseInvoice | Gets the purchaseinvoice of the dimensionSetLine. |
purchaseInvoiceLine | purchaseInvoiceLine | Gets the purchaseinvoiceline of the dimensionSetLine. |
vendorPayment | vendorPayment | Gets the vendorpayment of the dimensionSetLine. |
salesShipment | salesShipment | Gets the salesshipment of the dimensionSetLine. |
salesShipmentLine | salesShipmentLine | Gets the salesshipmentline of the dimensionSetLine. |
purchaseReceipt | purchaseReceipt | Gets the purchasereceipt of the dimensionSetLine. |
purchaseReceiptLine | purchaseReceiptLine | Gets the purchasereceiptline of the dimensionSetLine. |
purchaseOrder | purchaseOrder | Gets the purchaseorder of the dimensionSetLine. |
purchaseOrderLine | purchaseOrderLine | Gets the purchaseorderline of the dimensionSetLine. |
PS: Dynamics 365 Business Central: How to use filter expressions in API related resource ($expand)
Properties:
Property | Type | Description |
---|---|---|
id | GUID | The unique ID of the dimension set line. Non-editable. |
code | string | The code of the dimension set line. |
parentId | GUID | The ID of the parent entity. |
parentType | NAV.dimensionSetEntryBufferParentType | The type of the parent document of the dimension set line. It can be ” “, “Journal Line”, “Sales Order”, “Sales Order Line”, “Sales Quote”, “Sales Quote Line”, “Sales Credit Memo”, “Sales Credit Memo Line”, “Sales Invoice”, “Sales Invoice Line”, “Purchase Invoice”, “Purchase Invoice Line”, “General Ledger Entry” or “Time Registration Entry”. |
displayName | string | Specifies the dimension set line’s name. This name will appear on all sales documents for the dimension set line. |
valueId | GUID | The unique ID of the value of the dimension. |
valueCode | string | The code of the value of the dimension. |
valueDisplayName | string | The display name of the value of the dimension. Read-Only. |
Source code: page 30022 “APIV2 – Dimension Set Lines”
Let’s look at some simple examples.
Get:
salesOrders -> dimensionSetLines
https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/salesOrders(28ac0679-16b4-ee11-a56a-000d3accbc4a)/dimensionSetLines
Response:
{
"@odata.etag": "W/\"JzE5OzMyMDgxNjE2NDkzMjc2NTM1MDcxOzAwOyc=\"",
"id": "14be2193-90ab-ee11-a56a-6045bd686202",
"code": "AREA",
"consolidationCode": "",
"parentId": "28ac0679-16b4-ee11-a56a-000d3accbc4a",
"parentType": "Sales_x0020_Order",
"displayName": "Area",
"valueId": "77fb0da5-90ab-ee11-a56a-6045bd686202",
"valueCode": "40",
"valueConsolidationCode": "",
"valueDisplayName": "Europe North (Non EU)"
}
PS: In BC
Another example:
purchaseInvoices -> dimensionSetLines
https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/purchaseInvoices(3ca0d8f6-fdb3-ee11-a56a-000d3accbc4a)/dimensionSetLines
Post:
https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/salesOrders(28ac0679-16b4-ee11-a56a-000d3accbc4a)/dimensionSetLines
Header:
Body:
{
"parentId": "28ac0679-16b4-ee11-a56a-000d3accbc4a",
"code": "BUSINESSGROUP",
"valueCode": "Home"
}
Patch:
https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/salesOrders(28ac0679-16b4-ee11-a56a-000d3accbc4a)/dimensionSetLines(15be2193-90ab-ee11-a56a-6045bd686202)
Header:
Body:
This is not difficult. So the next question is, is this possible via Power Automate? Unfortunately, as of now, this cannot be done via the standard API. Although this standard API can be selected in the Power Automate trigger.
But it will prompt the following error. (Parent Id is already set)
ErrorCode: Application_DialogException
You must get to the parent first to create a dimension set line.
Why? AJ gave a detailed explanation. More details: Link
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.
PS:
1. Using OAuth 2.0 to connect Business Central APIs and Web Services in Power Automate – OAuth in HTTP action (standard HTTP action in Power Automate)
2. For the default dimensions of master data, please use the standard API below.
defaultDimension resource type: Represents a default dimensions in Business Central.
END
Hope this will help.
Thanks for reading.
ZHU
コメント