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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Company Address based on Purpose using X++

(0) ShareShare
ReportReport
Posted on by 2,426

Good Morning,

i am trying to fetch company address.

companyinfo::find().postaladdress().address

this is actually giving the address which is primary and purpose is Business.

I am actually tring to fetch Address for company which is not primary and Purpose type is not bussiness that means UserDefined(any thing other than business ).

Please tell me how can i get the address details .

Please show some light on this.

Regards.

Have a great day.

 

*This post is locked for comments

I have the same question (0)
  • junior AX Profile Picture
    1,552 on at
    RE: Company Address based on Purpose using X++

    Hi Ajit,

    but i don't want to filter by Role i want to filter by name plus logistics postal address table doesn't contain a field called location Role.

    here's what i want exactly i have an address book called x, it contains two addresses as you can see in the picture(tt,x) if you click on each address, you'll see a grid  with fields: name or description,address and purpose 
    i want to show these fields for each address only if the purpose was for each one ="mail to"


    ss11.png

    ss11.png

  • Suggested answer
    Ajit Profile Picture
    8,755 on at
    RE: Company Address based on Purpose using X++

    You can write a query to get all address based on the location role using LogisticsPostalAddress table. You can refer method findPostalAddressByRole method of DirParty class for more details.

  • junior AX Profile Picture
    1,552 on at
    RE: Company Address based on Purpose using X++

    What if i want to get all the addresses of purpose:"Mail To" not just the company

    I'm trying to write a job that shows every address related to that purpose

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: Company Address based on Purpose using X++

    Hi,

    Have you tried the method I posted earlier(provided below), if not please try it. 

    container addressDetails;
        
        // Phone
        addressDetails = DirParty::electronicAddressLocatorsByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,
                                                                   LogisticsElectronicAddressMethodType::Email,
                                                                   enum2str(LogisticsLocationRoleType::None));
        info(strFmt("MailId: %1",conPeek(addressDetails, 1)));
        
        // EmailId
        addressDetails = DirParty::electronicAddressLocatorsByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,
                                                                  LogisticsElectronicAddressMethodType::Phone,
                                                                  enum2str(LogisticsLocationRoleType::None));
        info(strFmt("Phone: %1",conPeek(addressDetails, 1)));


  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Company Address based on Purpose using X++

    I dont know whether i am right or wrong,

    I am getting values from this code

    static void Job15(Args _args)
    {
    Addressing address;
    logisticslocationentity loglocentity;

    address = DirParty::findPostalAddressByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,LogisticsLocationRoleType::None).getAddress();
    info(strFmt("%1",address));

    loglocentity = DirParty::primaryElectronicAddressLocation(DirPartyTable::find(companyInfo::find().PartyNumber).RecId);

    info(strFmt("%1",loglocentity.getEmail()));
    info(strFmt("%1",loglocentity.getPhone()));
    }

    Regards.

    Have a great day.

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Company Address based on Purpose using X++

    Hi,

    Addressing address;
    container addressDetails;

    address = DirParty::findPostalAddressByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,LogisticsLocationRoleType::None).getAddress();
    info(strFmt("%1",address));

    addressDetails = DirParty::electronicAddressLocatorsByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,
    LogisticsElectronicAddressMethodType::Email,
    enum2str(LogisticsLocationRoleType::None));
    info(strFmt("MailId: %1",conPeek(addressDetails, 1)));

    I am not getting any value.

    Regrads.

    Have a great day.

  • Ajit Profile Picture
    8,755 on at
    RE: Company Address based on Purpose using X++

    You might not have value for that particular parameters. Paste your line of code here.

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Company Address based on Purpose using X++

    i am getting 0 value

  • Ajit Profile Picture
    8,755 on at
    RE: Company Address based on Purpose using X++

    What's wrong? Are you getting an error?

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Company Address based on Purpose using X++

    Hi ajit,

    this method is not working.

    Please suggest .

    Regards.

    Have a great day.

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

Responsible AI policies

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
KP-31070522-0 Profile Picture

KP-31070522-0 3

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans