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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Customer address through code in AX 2012 r3

(0) ShareShare
ReportReport
Posted on by 56

hi

2627.A2.jpg

i wrote below code to display address of customer, BUT it's not printing the "Japan"

while select AccountNum,party from custTable where custTable.AccountNum == customerCode
    {
        if(custTable)
        {
            party       = custTable.Party;
            description = DirParty::primaryPostalAddress(party).displayLocationDescription();
            address     = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Delivery);

            // phone -- customer
            logisticsElectronicAddress = DirParty::primaryElectronicAddress(party, LogisticsElectronicAddressMethodType::Phone);
            if(logisticsElectronicAddress)
            {
                locator = logisticsElectronicAddress.Locator;
            }

            // fax -- customer
            logisticsElectronicAddress2 = DirParty::primaryElectronicAddress(party, LogisticsElectronicAddressMethodType::Fax);
            if(logisticsElectronicAddress2)
            {
                locator2 = logisticsElectronicAddress2.Locator;
            }

        }
    }

Output

6076.report2.jpg

Please give me more shed on this.

thanks!

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Arpan,

    It is not sure from your code which field you are choosing to display address.

    Can you share the entire code that you are using?

  • @rp@n Profile Picture
    56 on at

    select salesInvoiceHeaderFooterTmp;
    salesInvoiceHeaderFooterTmp.Address         = address;
    
    salesInvoiceHeaderFooterTmp.insert();

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    There is nothing wrong with this call. You may want to check the data in LogisticsPostalAddress Table.

    An alternative could be to write your own method -

    public static Addressing getPostalAddressByType(DirPartyRecId _party, LogisticsLocationRoleType _type)
    {
        DirPartyLocation        partyLocation;
        DirPartyLocationRole    partyLocationRole;
        LogisticsLocation       location;
        LogisticsLocationRole   locationRole;
        LogisticsPostalAddress  postalAddress;
    
        select firstonly postalAddress
            exists join location
                where location.RecId == postalAddress.Location
            exists join locationRole
                where locationRole.Type  == _type//LogisticsLocationRoleType::Invoice
            exists join partyLocation
                where 
                    partyLocation.Location      == location.RecId &&
                    partyLocation.IsPrimary     == NoYes::Yes && 
                    partyLocation.Party         == _party
            exists join partyLocationRole
                where partyLocationRole.PartyLocation   == partyLocation.RecId &&
                    partyLocationRole.LocationRole      == locationRole.RecId;
    
        return postalAddress.Address;
    }

    Also, it looks like you are trying to get the Delivery address for a sales order. Can you not use the SalesTable\deliveryAddress method?

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Arpan,

    Were you able to resolve this issue?

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    If you debug and see you are getting full value in your address variable its a problem  where you are printing it. How /Where do you printing your output ?

  • WillWU Profile Picture
    22,363 on at

    Hi @rp@n,

    Where is your code to output the address? I can't find it.

    This line will return the Delivery address of your customer. DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Delivery)

    Have you used a placeholder somewhere? I suggest you print out the address directly and check it.

    Hope this helps.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 681 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 551 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 471

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans