CustTable custTable = CustTable::find('12345');
LogisticsPostalAddress logisticsPostalAddress = custTable.postalAddress();
DirPartyLocationRole entityLocationRole;
container roleRecIds, roleNames, roleTranslationRecIds;
LogisticsLocationRole locationRole;
LogisticsLocationRoleTranslation locationRoleTransl;
DirPartyLocation dirPartyLocation;
// Addresses
info(strFmt("Address: %1", logisticsPostalAddress.Address));
select dirPartyLocation
where dirPartyLocation.Location == logisticsPostalAddress.Location
&& dirPartyLocation.Party == custTable.Party;
info('Address purposes:');
//DirPartyLocation.locationRoles()
while select LocationRole from entityLocationRole
where entityLocationRole.PartyLocation == dirPartyLocation.RecId
join Name from locationRole
order by locationRole.Name
where locationRole.RecId == entityLocationRole.LocationRole
&& locationRole.Type != LogisticsLocationRoleType::OneTime
outer join Description from locationRoleTransl
where locationRoleTransl.LocationRole == locationRole.RecId
&& locationRoleTransl.LanguageId == currentUserLanguage()
{
info((locationRoleTransl.Description == '' ? locationRole.Name : locationRoleTransl.Description));
}
// Contact information
LogisticsElectronicAddress electronicAddress = DirParty::primaryElectronicAddress(custTable.Party, LogisticsElectronicAddressMethodType::Phone);
info(strFmt("Phone: %1", electronicAddress.Locator));
info('Phone purposes:');
LogisticsElectronicAddressRole logisticsElectronicAddressRole;
UserInfo userInfo;
//LogisticsElectronicAddress.locationRoles()
while select LocationRole from logisticsElectronicAddressRole
join Name from locationRole
outer join Description from locationRoleTransl
exists join userInfo
order by locationRole.Name
where logisticsElectronicAddressRole.LocationRole == locationRole.RecId &&
logisticsElectronicAddressRole.ElectronicAddress == electronicAddress.RecId &&
(locationRole.Type != LogisticsLocationRoleType::OneTime) &&
locationRoleTransl.LocationRole == locationRole.RecId &&
locationRoleTransl.LanguageId == userInfo.Language &&
userInfo.Id == curUserId()
{
info((locationRoleTransl.Description == '' ? locationRole.Name : locationRoleTransl.Description));
}
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a CoffeeNo comments. Be the first one to comment on this post.
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.