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

Popular posts from this blog

x++ code to add hyperlink to a field in D365FO

x++ code to get Vendor Email Address based on Purpose in Dynamics 365 for Operations