Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Company Address based on Purpose using X++

(0) ShareShare
ReportReport
Posted on by 2,420

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

  • junior AX Profile Picture
    junior AX 1,548 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
    Ajit 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
    junior AX 1,548 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
    Chaitanya Golla 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
    AX 2012 r3 2,420 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
    AX 2012 r3 2,420 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
    Ajit 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
    AX 2012 r3 2,420 on at
    RE: Company Address based on Purpose using X++

    i am getting 0 value

  • Ajit Profile Picture
    Ajit 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
    AX 2012 r3 2,420 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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans