x++ code to get country region id based on legal entity

static void test (Args _args)
{
    CompanyInfo                         companyInfo;
    DirPartyTable                       dirPartyTable;
    LogisticsLocation                   logisticsLocation;
    LogisticsEntityPostalAddressView    logisticsEntityPostalAddressView;
    ;

    companyInfo = CompanyInfo::find();
 
   dirPartyTable   = DirPartyTable::find(companyInfo.PartyNumber);

   select firstonly IsPostalAddress,Recid,LocationId from   logisticsLocation
            where  logisticsLocation.RecId  == dirPartyTable.PrimaryAddressLocation
             && logisticsLocation.IsPostalAddress == NoYes::Yes ;

    info(strFmt(" location id %1 ",logisticsLocation.LocationId));

    select firstonly  IsPrimary,CountryRegionId,Location  from  logisticsEntityPostalAddressView
            where logisticsEntityPostalAddressView.IsPrimary == NoYes::Yes
            &&  logisticsEntityPostalAddressView.Location == logisticsLocation.RecId;

    info(strFmt("%1 ",logisticsEntityPostalAddressView.CountryRegionId));

}

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

x++ code to get Customer Address based on purpose in ax 2012