web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Working with the Inventory Visibility Service for Dynamics 365 Supply Chain Management (part 1)

Henrik Larsen Profile Picture Henrik Larsen

As you probably know, Dynamics 365 Supply Chain Management (D365SCM) now comes with a hyperscale microservice that allows external systems to interact in real-time with inventory in D365SCM. The service is described in more detail here.

In this two-part article, I am going to explore how we can call the service and use the data in an external app (Power Apps). In this first part, I will be looking at how to call the service through its inbuilt REST API.

Before I get to call the service, I need to install and configure it. Once the service has been installed and configured, you can use the instructions in this article to start calling the API.

In my example, I would like to create an app that shows me available inventory for a specific combination of organisation, site, warehouse and product.

Instead of making the call directly from the app, I create a Power Automate flow that makes the call and returns the result as a JSON payload to the app as shown in the following screenshot.

Power Automate Flow Calling the Inventory Visibility Service

As you can see, the flow is invoked by a Power Apps app and will end by responding back to the app.

The first action takes the product ID (ItemID) as a parameter from the app to use in the on-hand query.

The second action calls Azure Active Directory (AAD) to retrieve an access token based on the configuration I made when installing the service as shown below.

Retrieve Access Token from Azure Active Directory

The response from AAD is in JSON format so in the next action I parse the JSON to get the actual access token for use in the next step.

In the next step I use the access token retrieved from AAD to get an access token from the service as shown in this screenshot. The variable used in the client_assertion attribute is the AAD access token retrieved above.

Retrieve Access Token from Inventory Visibility Service

Please note that you may get and error 307 (temporary redirect) when calling the service. In the response header from the service, using the Location key, you can find the actual URL pointing to the service endpoint.

Again, the response is in JSON format, so we parse this, but now we have the access token we need to actually query the service.

In the last action I now query the service to retrieve on-hand inventory for organisation=usmf, site = 1, warehouse = 11 and product = 1000 as shown here.

Onhand Inventory Query

Obviously, when I create the app in the next part of this series, I will extend my flow to take site and warehouse as parameters and use these as variables in the query.

This is what the result of the query looks like:

[

  {

    “productId”: “1000”,

    “dimensions”: {

      “siteid”: “1”,

      “locationid”: “11”

    },

    “quantities”: {

      “fno”: {

        “arrived”: 0,

        “availordered”: 1265,

        “availphysical”: 293,

        “deducted”: 1,

        “onorder”: 76,

        “ordered”: 1048,

        “physicalinvent”: 293,

        “postedqty”: 294,

        “quotationreceipt”: 13,

        “reservordered”: 0,

        “reservphysical”: 0

      },

      “iv”: {

        “ordered”: 0,

        “softreservphysical”: 0,

        “softreservordered”: 0,

        “reservphysical”: 0,

        “reservordered”: 0,

        “orderedtotal”: 1048,

        “onhand”: 293,

        “openorder”: 76,

        “onhandavailable”: 293,

        “availabletoreserve”: 1341,

        “inventorysupply”: 1341,

        “inventorydemand”: 76

      },

      “iom”: {

        “onhand”: 0,

        “onorder”: 0

      },

      “sap”: {

        “unrestricted”: 0,

        “qualityinspection”: 0

      },

      “pos”: {

        “inbound”: 0,

        “outbound”: 0,

        “availquantity”: 293

      }

    }

  }

]

As mentioned, in the next part in this two-part series, I will create an app that calls this flow and presents the result in a meaningful way.


This was originally posted here.

Comments

*This post is locked for comments