Below are the solutions to get customers by address type(Invoice , delivery)
Solution 1
------------------
display Addressing InvoicingAddress()
{
Addressing address;
DirPartyRecId party;
party = CustTable::find(‘Account’).Party;
address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Invoice);
if (!address)
address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Delivery);
return address;
}
Solution 2
--------------
select firstonly postalAddress
return postalAddress;
Solution 1
------------------
display Addressing InvoicingAddress()
{
Addressing address;
DirPartyRecId party;
party = CustTable::find(‘Account’).Party;
address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Invoice);
if (!address)
address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Delivery);
return address;
}
Solution 2
--------------
//LogisticsLocationRoleType (Invoice, Delivery, Shipping etc.)
public static LogisticsPostalAddress getPostalAddressByType(DirPartyRecId _party, LogisticsLocationRoleType _type)
{
DirPartyLocation partyLocation;
DirPartyLocationRole partyLocationRole;
LogisticsLocation location;
LogisticsLocationRole locationRole;
LogisticsPostalAddress postalAddress;
select firstonly postalAddress
exists join location
where location.RecId == postalAddress.Location
exists join locationRole
where locationRole.Type == _type//LogisticsLocationRoleType::Invoice
exists join partyLocation
where
partyLocation.Location == location.RecId &&
partyLocation.IsPrimary == NoYes::Yes &&
partyLocation.Party == _party//custtable.party
exists join partyLocationRole
where partyLocationRole.PartyLocation == partyLocation.RecId &&
partyLocationRole.LocationRole == locationRole.RecId;
return postalAddress;
}
No comments:
Post a Comment