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 :
Finance | Project Operations, Human Resources, ...
Unanswered

find warehouse address taking into account address purpose

(1) ShareShare
ReportReport
Posted on by 919
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)

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 814 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 622

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=_hemalatha%26)" - Too many )'s.