Locating Primary Contact Information for a Specific Warehouse using Dynamics AX

By Bill Thompson | May 31, 2016

Locating primary contact information for a specific warehouse using dynamics ax

This week I am going to talk about how to find the primary contact person and their phone number for a specific warehouse. This information in Dynamics AX is defined in Warehouse management >> Setup >> Warehouse setup >> Warehouses. You locate the warehouse in question and go to the Address fast tab. I had to click the Edit button as the demo data does not have this defined for the address I was wanting. On the New address form, you can enter in the contact information in the Contact information fast tab.

Warehouse management

Once this is done, the following job will find the contact information for the warehouse tied to a specific shipment.

Warehouse management

static void testContactLogic(Args _args)
    WHSShipmentTable        		shipmentTable = WHSShipmentTable::find('USMF-000002');

    InventLocation                  	inventLocation;
    LogisticsEntityPostalAddressView    	postalAddressView;
    LogisticsElectronicAddress          	electronicAddress;
    LogisticsLocation                   	contactLocation;

    inventLocation = inventLocation::find(ShipmentTable.InventLocationId);
    if (inventLocation)
        select firstonly postalAddressView
            where   postalAddressView.Entity     == inventLocation.RecId
            &&      postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
            &&      postalAddressView.isPrimary  == NoYes::Yes;

        if (postalAddressView)
            select firstOnly electronicAddress where electronicAddress.Type == LogisticsElectronicAddressMethodType::Phone
            join contactLocation where contactLocation.ParentLocation  == postalAddressView.Location
                && contactLocation.RecId == electronicAddress.Location;

            info(strFmt("Primary contact name: %1  Primary contact phone: %2",electronicAddress.Description, electronicAddress.Locator));

Please note this code could be optimized with more joins. I intentionally created the job above in this manner to more clearly demonstrate the relations needed, AND make it easier to step through via the debugger if so desired.

Oh, of course, I should show the output of this job as well:

Primary contact information for warehouse management

The above code could easily the modified for email, all contacts, etc.  This just demonstrates retrieving specific desired information for a specific warehouse based on shipment information.

Happy coding.

Related Posts

Recommended Reading:

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!