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)

Assign a phone/email to a specific customer address

(0) ShareShare
ReportReport
Posted on by 2,894

Hi, I'm working in AX 2012 creating customers and their addresses in X++. I am also adding phone numbers and email addresses to the postal address, by using this code:

    DirPartyContactInvfoView;
    DirParty dirParty = new DirParty(dirPerson);

    dirPartyContactInfo.LocationName = "Main email";
    dirPartyContactInfo.Locator = test@mail.com";
    dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Email;
    dirPartyContactInfo.IsPrimary = NoYes::Yes;

    dirParty.createOrUpdateContactInfo(dirPartyContactInfo);

It works great, however, when I add more than one address, I don't know how to add contact information (phone, email) for those extra addresses, because these contacts that I'm currently creating remains in the "main" form:

example2.png

Instead of being assigned to each addresses, which is what I need, so they appear in this area for each address:

Any idea how to assign contacts to specific addresses using X++? I would appreciate your help, thanks!




*This post is locked for comments

I have the same question (0)
  • Verified answer
    Bilal Issa Profile Picture
    4,370 on at

    Hi ,

    please try the following code.

       LogisticsLocation                   contactLogisticsLocation,addressLogisticsLocation;

       LogisticsPostalAddress              postalAddress;

       DirPartyContactInfoView             dirPartyContactInfo;

       LogisticsContactInfoView            contactInfoView;

       LogisticsElectronicAddress          elecAddress;

       ;

       // find the new address you have added

       postalAddress  = LogisticsPostalAddress ::findRecId(37262525);

       addressLogisticsLocation = LogisticsLocation::find(postalAddress.location);

       contactLogisticsLocation.clear();

       contactLogisticsLocation.initValue();

       contactLogisticsLocation.ParentLocation = LogisticsLocation::findByLocationId (addressLogisticsLocation.LocationId).RecId;

       contactLogisticsLocation.IsPostalAddress = NoYes::No;

       contactLogisticsLocation.insert();

       dirPartyContactInfo.LocationName = "Main email";

       dirPartyContactInfo.Locator = "test@mail.com";

       dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Email;

       dirPartyContactInfo.IsPrimary = NoYes::Yes;

       dirPartyContactInfo.Location = contactLogisticsLocation.RecId;

       // Create electronic address

       elecAddress.initValue();

       contactInfoView.initFromPartyContactInfoView(dirPartyContactInfo);

       elecAddress = LogisticsElectronicAddressEntity::initFromLogisticsContactInfoView(contactInfoView, elecAddress);

       // Insert

       if (elecAddress.validateWrite())

           elecAddress.insert();

  • saman0suke Profile Picture
    2,894 on at

    Thanks a lot for the code, I tried it and I did not receive any error, but I don't see the contact that was supposed to be created.  I made a little modification and it worked!. I did not use anything after elecAddress.initValue, instead of that I used a DirParty class buffer, and called the method createOrUpdateContactInfo and provided the recently created buffer of dirPartyContactInfoView and that worked, thanks a lot!!

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