dynamics-business-central

Retrieve all dimensionSetLines for all SalesOrders


Is it possible to retrieve dimensionSetLines for all SalesOrders in one request using Business Central API. Not just retrieve dimensionSetLines for a specific SalesOrder but for all of them.

I wanted to know if this is possible.


Solution

  • You can't retrieve the Dimension Set Lines directly. You have to go through the parent i.e., the Sales Orders.

    However you can still retrieve the required data in one API-call with some clever usage of the OData protocol:

    An example of the API call could be as follows (using REST Client in Visual Studio Code):

    @auth = Bearer [Access Token]
    
    GET https://api.businesscentral.dynamics.com/v2.0/[Tenant ID]/[Environment Name]/api/v2.0/salesOrders?$select=id,number&$expand=dimensionSetLines
    Company: [Company Name]
    Authorization: {{auth}}