1

I need to query the short name of the country name based on custtable.

I know the information lies in

LogisticsAddressCountryRegionTranslation.shortname;
 LogisticsAddressCountryRegion.countryregionid;

Problem is, going through the relations i don't see a way to link back to custtable. There used to be a countryregionid in the custtable that would link back but it is changed to DEL_countryregionid and cannot use this anymore. How can i obtain this information. Using ax 2012

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
Sirus
  • 382
  • 1
  • 8
  • 35

1 Answers1

2

An important thing to note is a Customer record can have multiple addresses. So this answer uses the Primary Postal Address. This may not be your use case.

Also the "ShortName" is region specific.

static void Job20(Args _args)
{
    CustTable                                   custTable;
    LogisticsAddressCountryRegionTranslation    countryRegionTranslation;
    UserInfo                                    userInfo;
    LogisticsAddressCountryRegion               countryRegion;
    LogisticsPostalAddress                      postalAddress;

    select firstOnly custTable;

    postalAddress = custTable.postalAddress();

    countryRegion   = LogisticsAddressCountryRegion::find(postalAddress.CountryRegionId);

    select firstonly Language from userInfo where userInfo.Id == curUserId()
        join countryRegionTranslation
            where countryRegionTranslation.CountryRegionId == countryRegion.CountryRegionId &&
                    countryRegionTranslation.LanguageId      == userInfo.Language;

    info(strFmt("Address: %1; ShortName: %2", postalAddress.Address, countryRegionTranslation.ShortName));
}
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71