Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Create contactperson via x++

(0) ShareShare
ReportReport
Posted on by

Hello Folks,

I am trying to create contact person ID through code.

I did followed this code here from community and replaced ContactPersonEntity  of Ax2012 with ContactPersonSyncEntity  in D365 and got errors at line of code which I have shared below (please excuse for not using code snippet in the way it is intended to be used).

Please suggest a fix for errors and numseq issue described in below snippet.

ContactPersonSyncEntity contactPersonSyncEntity ;
//Get State not found error at below line of code.

  // Update the postal address information.
       contactPersonSyncEntity .createOrUpdatePostalAddress(postalAddress);

//When I comment above code to continue with execution next error I get stating contact person id should be there from below line of code.
  // Update the contact information.
        contactPersonSyncEntity .createOrUpdateContactInfo(contactInfo);


//Which is strange because before this line of code there is the code 
contactPersonSyncEntity .parmContactPersonId('CP64');
//Also will be nice f you can share how to get contatPersonId from contactperson number seqeunce sued at legal entity level

Thanks in advance

Mav

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,969 Super User 2025 Season 1 on at
    RE: Create contactperson via x++

    Hi Mav,

    Why should this post be deleted? Do you still need help with your addresses state issue?

  • Mav Profile Picture
    Mav on at
    RE: Create contactperson via x++

    Admin please delete this thread.

  • Mav Profile Picture
    Mav on at
    RE: Create contactperson via x++

    Hello All,

    I have resolved all the issues with contactperson ID error however unable to resolve one issue which is state not found and it comes at this line below and you will notice that we are supplying the state as WA.

           contactPersonEntity.createOrUpdatePostalAddress(postalAddress);

  • Mav Profile Picture
    Mav on at
    RE: Create contactperson via x++

    Hello,

    Thanks for your note.

    Requirement is to create contact in d365 via x++, for which I had followed the steps shared in community thread, ,link of which I have shared in my initial post.

    Issue is that I get errors while using the code shared in the thread, details of which error is faced at what line of code are shared in the code snippet in my 1st post.

    Form location is Sales and marketing>Relationships>Contacts.

    Thanks

    Mav

  • AnithaEswaran Profile Picture
    AnithaEswaran 2,032 on at
    RE: Create contactperson via x++

    Hi Mav,

    can you please explain your requirement ? In which F&O form are you trying to insert the data..

  • Mav Profile Picture
    Mav on at
    RE: Create contactperson via x++

    Hello folks,

    Any update on this would be really helpful.

    Thanks

    Mav

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans