2017-01-30 5 views
1

나는 custtable에 근거한 국가 이름의 짧은 이름을 질문 할 필요가있다.custtable에서 국가의 짧은 이름을 찾는 방법

나는 정보, 관계 겪고 난 custtable 다시 연결하는 방법을 볼 수 없습니다되어

LogisticsAddressCountryRegionTranslation.shortname; 
LogisticsAddressCountryRegion.countryregionid; 

문제에있다 알고있다. 이전에는 연결 고리에있는 국가 기록이 있었지만 DEL_countryregionid로 변경되어 더 이상 사용할 수 없습니다. 이 정보는 어떻게 얻을 수 있습니까? Using ax 2012

답변

2

중요한 것은 고객 레코드가 여러 개의 주소를 가질 수 있다는 점입니다. 따라서이 대답은 주 우편 주소을 사용합니다. 이것은 유스 케이스가 아닐 수도 있습니다.

또한 "ShortName"은 지역에 따라 다릅니다.

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)); 
}