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

Notifications

Announcements

No record found.

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)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Please use the following job to get the details of the address(es) specified on company info for the current company.

    static void CompanyAddress(Args _args)
    {
        CompanyInfo companyInfo;
        LogisticsPostalAddress  postalAddress;
        DirPartyLocation partyLocation;
        LogisticsLocationRole   locationRole;
        DirPartyLocationRole    partyLocationRole;
        
       while select companyInfo
           where companyInfo.DataArea == curext()
        join partyLocation
            where partyLocation.Party == companyInfo.RecId 
        join postalAddress        
            where postalAddress.Location == partyLocation.Location
        join partyLocationRole       
            where partyLocationRole.PartyLocation == partyLocation.RecId       
        join locationRole      
           where partyLocationRole.LocationRole == locationRole.RecId       
            //&& partyLocation.IsPrimary == true
        {
            info(strFmt("Purpose: %1, IsPrimary: %2, Address %3",locationRole.Type, partyLocation.IsPrimary,  postalAddress.Address));      
        }
    }

  • Verified answer
    Ajit Profile Picture
    8,755 on at

    Try this -

    DirParty::findPostalAddressByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,LogisticsLocationRoleType::Invoice);

  • Verified answer
    AX 2012 r3 Profile Picture
    2,426 on at

    Thank you so much for replying.

    with your answers i wrote this and working fine

     Addressing address;

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

     

    Regards.

    Have a great day.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    How can i get Mobile Number and Emailid for this.

    Please provide i tried searching for field locator but not available

    Please help.

    Regards.

    Have a great day.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Please show some light on this

    i am waiting for your replies.please do reply

    Regards.

  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    We have a method for electronic addresses as well -

    DirParty::findElectronicAddressByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,LogisticsElectronicAddressMethodType::Phone,LogisticsLocationRoleType::Business);

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Please use the following code

    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)));

    Following method is shown as deprecated on AX2012R3
    ElectronicAddress.jpg
    LogisticsElectronicAddress electronicAddress;
        
        electronicAddress = DirParty::findElectronicAddressByRole(DirPartyTable::find(companyInfo::find().PartyNumber).RecId,
                                                                                      LogisticsElectronicAddressMethodType::Email,
                                                                                      LogisticsLocationRoleType::Business);
        info(strFmt("%1",electronicAddress.Locator));

  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    Ok. Use this method DirParty::electronicAddressLocatorsByRole if that is deprecated.

  • AX 2012 r3 Profile Picture
    2,426 on at

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans