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

Announcements

No record found.

News and Announcements icon
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
    303,362 Super User 2026 Season 1 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
    303,362 Super User 2026 Season 1 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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans