x++ code to get Customer Address based on purpose in ax 2012
static void customerAddress(Args _args)
{
DirPartyPostalAddressView dirPartyPostalAddrlocal;
DirPartyLocationRolesView dirPartyLocationRoleslocal;
LogisticsLocationRole logisticsLocRole;
select firstOnly * from dirPartyPostalAddrlocal order by RecId desc
exists join dirPartyLocationRoleslocal
where dirPartyLocationRoleslocal.Location == dirPartyPostalAddrlocal.Location
&& dirPartyLocationRoleslocal.Party == CustTable::find(_accountNum).Party//_dirpartyRecid
//&& dirPartyPostalAddrlocal.IsPrimary == NoYes::No
exists join logisticsLocRole
where logisticsLocRole.Name == _purpose //like Delivery,Invoice,Business
&& logisticsLocRole.RecId == dirPartyLocationRoleslocal.LocationRole
&& logisticsLocRole.IsPostalAddress;
info(strfmt("%1",dirPartyPostalAddrlocal .address));
Comments
Post a Comment