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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Get warehouse address based on Logistics location role type

(0) ShareShare
ReportReport
Posted on by

Hi,

I want to get warehouse addres baesd on the role type(Delivery,invoice).

I used below code to get address based on invoice but i coundn't .

logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(inventLocation, LogisticsLocationRoleType::Invoice) 

How can i acheive this.

Thanks in advance.

I have the same question (0)
  • udaY-ch Profile Picture
    5,128 on at

    Hi

    What's so wrong in here, Missing semicolon at the end is what I can find in the code.

    I assume you got the correct invent location buffer. can you please share your complete code and let us know what is the problem here.

    If you ever find hard to get the code then there is a nice feature available in the application has Find References which "Finds all of the X++ code and other elements that reference the selected element."

    Uday

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi John_pj,

    Could you, please, specify your issue?

    if you need to fetch one of the addresses (delivery or invoice), you can first fetch invoice address and if it's empty you can fetch delivery.

  • Community Member Profile Picture
    on at

    Hi Seigei,

    Thank you for the response, I have to fetch the invoice address from warehouse if the invoice address missing then i have to fetch delivery address based on invent location id. But by using the code i couldn't.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi john_pj,

    As i mentioned before you need first select invoice address and if it's empty select delivery address

    logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(inventLocation, LogisticsLocationRoleType::Invoice);
    
    if (logisticsPostalAddress.RecId == 0)
    {
        logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(inventLocation, LogisticsLocationRoleType::Delivery);
    }

  • Community Member Profile Picture
    on at

    Hi udhayachandranr,

    Thank You for your response.

    Here is the code:

              PurchPurchaseOrderHeader   purchPurchaseOrderHeader;

              purchtable purch =purchtable::find(purchPurchaseOrderHeader.PurchId);

            inventLocation = inventLocation::find(purch.InventLocationId);

            if (inventLocation)

            {

               logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(inventLocation, LogisticsLocationRoleType::Invoice);

                if (logisticsPostalAddress)

                {

                    select firstOnly electronicAddress where electronicAddress.Type ==

             LogisticsElectronicAddressMethodType::Phone

                join contactLocation where contactLocation.ParentLocation == logisticsPostalAddress.Location

                && contactLocation.RecId == electronicAddress.Location;

                    purchPurchaseOrderHeader.InvoiceAddress=logisticsPostalAddress.Address;

                   purchPurchaseOrderHeader.Phone=electronicAddress.Locator;

                }

            }

    But i am not getting the address based on invoice i am getting address based on delivery.What is the mistake here.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    It seems that there's some bug in LogisticsLocationEntity::findPostalAddress and that method doesn't return the invoice address.

    Looking at the code, it seems that if you ask for an address of an entity that's not related to a Party (warehouses are not) then it will ignore the LogisticsLocationRoleType parameter.

    I recommend reporting it as a bug to Microsoft support.

    By the way, why do you need the invoice address of a warehouse? You need a party (customer) for invoices. You can't invoice your own warehouses.

    Or are you asking your vendor to send invoice to your warehouse?

  • Community Member Profile Picture
    on at

    Hi Nikolaos,

    Thank you for the response.

    I need to show the warehouse invoice address  in the report(purchpurchaseorderreport)

  • Community Member Profile Picture
    on at

    Hi Sergei,

    Eventhough invoice address is present its showing delivery address only i dont know why.

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi John_pj,

    As Nikolaos said, address type is ignored in LogisticsLocationEntity::findLocation and it always return Delivery address (check LogisticsLocationEntityAppUtil.findLocation_find_subscriber method)

    You can still try to get invoice address with

    LogisticsLocationEntity::constructFromLocationRecId(InventLocation::getLocationFromRole(inventLocation.RecId, LogisticsLocationRoleType::Invoice)).getPostalAddress();

  • Community Member Profile Picture
    on at

    Hi Sergei,

    Thank you so much .Your code completely working fine.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans