web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get Address with Full Country Name

(0) ShareShare
ReportReport
Posted on by 563

Dear All,

I use Microsoft Dynamic AX 2012R3

I create a function to get primary address of customer

Here is my code

public String255 getPrimaryAddress(AccountNum _accountNum)
{
    CustTable       custTable;
    DirPartyTable   dirPartyTable;
    DirPartyLocation    dirPartyLocation;
    LogisticsLocation   logisticsLocation;
    DirPartyPostalAddressView postalAddressView;

    custTable       = custTable::find(_accountNum);
    dirPartyTable   = DirPartyTable::findRec(custTable.Party);
    dirPartyLocation    = DirPartyLocation::findPrimaryPartyLocation(dirPartyTable.RecId);
    logisticsLocation   = LogisticsLocation::find(dirPartyLocation.Location);
    postalAddressView   = DirPartyPostalAddressView::find(dirPartyTable.RecId,logisticsLocation.RecId);

    return postalAddressView.Address;
}

And this is an example of address I get

2437.address.png

As we can see, the bottom of address I can get short name of country

How to make it full name country?

Thanks in advance

Best Regards,

Bintang

*This post is locked for comments

I have the same question (0)
  • Rustem Galiamov Profile Picture
    8,072 on at

    Hi Bintang!

    What is your country short name and translation parameters?

    Screenshot-2018_2D00_10_2D00_23-at-09.33.57.png

  • Suggested answer
    startax Profile Picture
    1,845 on at

    Hi,

    This will always return Country code instead of Name. If you check DirPartyPostalAddressView it is using LogdticsPostaladdressView.

    Check LogdticsPostaladdressView.FormatAddress() method you will get more details

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Just to correct about formatAddress() method. 

    This method on LogisticPostalAddress table. And take a look at this piece of code:

    case LogisticsAddressElement::CountryRegion :
                        if (_countryRegion)
                        {
                            // <GEERU>
                            if (isRU)
                            {
                                if (countryRegionTranslation.ShortName)
                                {
                                    saveLogisticsAddress += countryRegionTranslation.ShortName + #Separators;
                                }
                                else
                                {
                                    select firstonly Language from userInfo where userInfo.Id == curUserId()
                                    join countryRegionTranslation
                                        where countryRegionTranslation.CountryRegionId == countryRegion.CountryRegionId &&
                                              countryRegionTranslation.LanguageId      == userInfo.Language;
                                    saveLogisticsAddress += (logisticsAddressFormatLinesFieldList.Expand && countryRegionTranslation.LongName ?
                                                             countryRegionTranslation.LongName                                                :
                                                             (countryRegionTranslation.ShortName ?
                                                              countryRegionTranslation.ShortName :
                                                              countryRegion.CountryRegionId)) + #Separators;
                                }
                            }
                            else
                            {
                            // </GEERU>
                                saveLogisticsAddress += ((logisticsAddressFormatLinesFieldList.Expand) ? #CountryRegionToken : _countryRegion) + #Separators;
                            // <GEERU>
                            }
                            // </GEERU>
                        }
                        break;


    As you can see, for Russian functionality the ShortName is used. You may create the same for your case.

  • Rustem Galiamov Profile Picture
    8,072 on at

    Hi Tahta Bintang Pratama!

    Did you solve the issue?

  • Bintang Profile Picture
    563 on at

    Hi Rustem Galiamov,

    Sorry for late reply

    I'm still try to understanding the code

  • Bintang Profile Picture
    563 on at

    I have checked the method formatAddress() and change it.

    But, I saw that even if you commenting all those lines inside LogisticsAddressElement::CountryRegion case, it doesn't affect how DirPartyPostalAddressView::find() function retrieve the address.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,411 Super User 2025 Season 2 on at

    Hi Bintang,

    If you go to the Address parameters form, you can manage address formats. On the line of the Country/Region, you can enable the 'Expand' option. When this is enabled, all new addresses from the country related to this address format, will then have the full name.

  • Bintang Profile Picture
    563 on at

    Hi André Arnaud de Calavon,

    Where is the 'Expand' option location? I can't find it

  • Bintang Profile Picture
    563 on at

    Hi André Arnaud de Calavon,

    I have find the Expand option, and I check it

    But doesn't change the country on address

    Is it need to restart AOS service?

  • André Arnaud de Calavon Profile Picture
    301,411 Super User 2025 Season 2 on at

    Hi Tahta,

    Like mentioned, it will format it when you create new/edit addresses. Existing addresses needs to be updated, e.g. with a script.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans