Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Get Address with Full Country Name

(0) ShareShare
ReportReport
Posted on by 555

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

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Get Address with Full Country Name

    Hi André Arnaud de Calavon,

    I succeed to update address with full country name check all expand option to Country/Region address format

    And then I update all address using batch job processing from this thread

    community.dynamics.com/.../210970

    Thank you for your help

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,391 Super User 2024 Season 2 on at
    RE: Get Address with Full Country Name

    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.

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Get Address with Full Country Name

    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?

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Get Address with Full Country Name

    Hi André Arnaud de Calavon,

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

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,391 Super User 2024 Season 2 on at
    RE: Get Address with Full Country Name

    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
    Bintang 555 on at
    RE: Get Address with Full Country Name

    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.

  • Bintang Profile Picture
    Bintang 555 on at
    RE: Get Address with Full Country Name

    Hi Rustem Galiamov,

    Sorry for late reply

    I'm still try to understanding the code

  • Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Get Address with Full Country Name

    Hi Tahta Bintang Pratama!

    Did you solve the issue?

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Get Address with Full Country Name

    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.

  • Suggested answer
    startax Profile Picture
    startax 1,845 on at
    RE: Get Address with Full Country Name

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans