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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

find warehouse address taking into account address purpose

(2) ShareShare
ReportReport
Posted on by 1,274
Hello,
 
I have a requirement to find warehouse address with purpose "Invoice" if it's marked as primary, if not then fetch the firstonly purpose "Invoice"  one if there are several of them. For instance on the screenshot below I have purpose invoice as primaty one. That's what I need BUt if it's not primary then I need to fetch the firstonly purpose invoice address form the list below. Is there any standard method I can use or I need to write my own?
 
I tried to use standard method
 
LogisticsPostalAddress address = LogisticsLocationEntity::findPostalAddress(
    this,
    LogisticsLocationRoleType::Invoice,
    DateTimeUtil::utcNow(),
    false);

but it returns me not Invoice address, but delivery one. however I passed this as argument LogisticsLocationRoleType::Invoice. this happens because under the hood it calls this. so just returns me delivery address.
 
 


if to use custom method as an option I see I can use such code
 
InventLocation inventLocation;
LogisticsEntityPostalAddressView postalAddressView;

inventLocation = inventLocation::find(inventlocation.InventLocationId);
if (inventLocation)
{
select firstonly postalAddressView
where postalAddressView.Entity == inventLocation.RecId
&& postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
&& postalAddressView.isPrimary == NoYes::Yes;
}
theres is a display method on the LogisticsEntityPostalAddressView called locationRoles() which returns purpose for the address. I can traverse through all addresses for the warehouse in LogisticsEntityPostalAddressView, then check if it's primary and of purpose invoice and return, otherwise proceed looking further firstonly of purpose invoice not primary. but i don;t think it's elegant solution.

maybe i can use some standard method?
 
Thanks.
I have the same question (0)
  • Verified answer
    dark_knight Profile Picture
    1,274 on at
    solved

    created a method like this one on InventTable
     
    public LogisticsPostalAddress getAddressByType(LogisticsLocationRoleType _roleType, TransDateTime _transDateTime = DateTimeUtil::utcNow())
    {
        LogisticsLocationEntity         location;
        LogisticsLocationRecId          logisticsLocationRecId;
            
        logisticsLocationRecId = InventLocation::getLocationFromRole(this.recid, _roleType, _transDateTime);
        location = LogisticsLocationEntity::constructFromLocationRecId(logisticsLocationRecId, false, _transDateTime);
    
        return location ? location.getPostalAddress() : null;
    }
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 609 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 561

#3
CP04-islander Profile Picture

CP04-islander 383

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans