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 :
Supply chain | Supply Chain Management, Commerce
Answered

What request/response to use to get the ItemAvailabilities used in InventoryLookupView

(0) ShareShare
ReportReport
Posted on by 1,455

I have to get the Ordered, Reserved and Inventory values for a specific product and InventLocationId that is shown on the InventoryLookupView.

I have tried in the CRT: GetItemAvailabilitiesByItemWarehousesServiceRequest/Response and GetItemAvailabilitiesDataRequest/EntityDataServiceResponse<ItemAvailability>.

All of them just returns a value in the ItemAvailability.AvailableQuantity field. none on the PhysicalReserved and OrderedSum. Even the AvailableQuantity doesn't correspond with what is shown in the InventoryLookupView.

Can anybody tell me what the request/response is that is actually behind orgUnitAvailability.ItemAvailabilities?

Thank you

I have the same question (0)
  • Verified answer
    Juliet Zhu Profile Picture
    on at
    RE: What request/response to use to get the ItemAvailabilities used in InventoryLookupView

    Hi Retha,

    The InventoryLookupView should ultimately call the SearchOrgUnitAvailabilitiesServiceRequest.

    Thank you for using Microsoft Dynamics Communities,

    Juliet Zhu

    SR SUPPORT ENG

    Microsoft Dynamics AX / Dynamics 365 Commerce

    If my information answers your question please click 'Yes' against "Did this answer your question?" to help other community members. 

  • Retha Profile Picture
    1,455 on at
    RE: What request/response to use to get the ItemAvailabilities used in InventoryLookupView

    Thank you SO MUCH for this information Juliet.

    I was able to use it in my CRT trigger and I finally have the same quantities that is shown in inventory lookup view.  I tried for the longest time to get the same quantities with a SQL view script but there was always an issue  somewhere with some product that it just doesn't gave the same quantities.

    For those that need to also add custom columns to show the same quantities that is on Inventory lookup, like I had to do for the product search view, here is what I did.

    *****

    I added a public class in my CRT project and extended it from IRequestTrigger:

    GetProductSearchTriggers : IRequestTrigger

    I added support request type: GetProductSearchResultsDataRequest, because I had to do it for the product search view.

    For the onExecuted method I looped through the products returned by the GetProductSearchResultsDataResponse and called the trigger Juliet gave me. It doesn't have a response , so I used the generic EntityDataServiceResponse but for entity OrgUnitAvailability.

    I added extension properties to each product specific for the 3 quantities, but I assume one can add the OrgUnitAvailability as an extension property and then on the POS side pulls out the values.

    public void OnExecuted(Request request, Response response)

    {

              var productsList = ((EntityDataServiceResponse<ProductSearchResult>)response);

               foreach (ProductSearchResult product in productsList)

               {

                   OrgUnitAvailabilitySearchCriteria srchCriteria = new OrgUnitAvailabilitySearchCriteria();

                   srchCriteria.OrgUnitName = request.RequestContext.GetOrgUnit().OrgUnitName;

                   srchCriteria.OrgUnitNumber = request.RequestContext.GetOrgUnit().OrgUnitNumber;

                   SearchOrgUnitAvailabilitiesServiceRequest availRequest = new SearchOrgUnitAvailabilitiesServiceRequest(

                       product.RecordId, srchCriteria, QueryResultSettings.AllRecords);

                   EntityDataServiceResponse<OrgUnitAvailability> availResponse =

                            request.RequestContext.Execute<EntityDataServiceResponse<OrgUnitAvailability>>((Request)availRequest);

                   PagedResult<OrgUnitAvailability> extensions = availResponse.PagedEntityCollection;

                   IEnumerable<ItemAvailability> fList = new List<ItemAvailability>();

                   foreach (OrgUnitAvailability obj in extensions)

                   {

                       fList = obj.ItemAvailabilities;

                       foreach(ItemAvailability vI in fList)

                       {

                               iQty += vI.AvailableQuantity;

                               rQty += vI.PhysicalReserved;

                               oQty += vI.OrderedSum;

                       }

                   }

                   CommerceProperty availPhys = new CommerceProperty();

                   availPhys.Key = "Inventory";

                   availPhys.Value = iQty.ToString("0.####");

                   product.ExtensionProperties.Add(availPhys);

                   CommerceProperty reserveQty = new CommerceProperty();

                   reserveQty.Key = "Reserved";

                   reserveQty.Value = rQty.ToString("0.####"); ;

                   product.ExtensionProperties.Add(reserveQty);

                   CommerceProperty orderQty = new CommerceProperty();

                   orderQty.Key = "Ordered";

                   orderQty.Value = oQty.ToString("0.####"); ;

                   product.ExtensionProperties.Add(orderQty);

               }

           }

    *****

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 875

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287 Super User 2025 Season 2

#3
Sagar Suman Profile Picture

Sagar Suman 235 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans