Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Adding contact to 'company' contact via API

(1) ShareShare
ReportReport
Posted on by 33
Hello,
 
We create customers (company type) via the standard API interface.
I am trying to add a contact for that customer also by API.
It seems I can only do that if I specify the company number (although looks like a contact no.) of the previously auto created contact. ie. "companyNumber = CT000076" in the contact create code.
 
My issue is how do I retrieve that CT number so I can create a new contact? Its not exposed by the customer endpoint and the contacts API cannot be searched by customer number or ID.
 
 
  • Verified answer
    IH-07071528-0 Profile Picture
    IH-07071528-0 33 on at
    Adding contact to 'company' contact via API
    Hello.
    Thanks for all your help. Now all sorted.
    For future searchers:
     
    1) Create a custom API to expose Contact Business Relation Table (5054).
    2) After creating a new customer. (Contact is auto created in our setup) use that API to return the 'Contact No' field where the 'No.' field is the customer number of the just created  customer. There will only be one as only just created customer.
    3) Create a new contact (type person) and fill the 'No.' field with the just returned value above.
    Not fully tested or error trapped yet but the basic method seems to work.
     
    Loving this software, incredibly well thought out and structured.
     
     
     
  • Verified answer
    gdrenteria Profile Picture
    gdrenteria 12,920 Most Valuable Professional on at
    Adding contact to 'company' contact via API
    Hi
    What our colleague Yun indicated is correct, if you want to customize or add functionality to an API you must customize it. Here I leave you some other interesting links, in addition to the link where you find the code for the standard APIs.
    Best
    GR
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,673 Super User 2024 Season 2 on at
    Adding contact to 'company' contact via API
    Hi, If this field is not included in the standard API, it needs to be customized.
    Dynamics 365 Business Central: Can we extend standard APIs? – Download Standard Source Code for APIs
     
    In addition, regarding automatically created contacts, you can actually set the system to not create them automatically.
    Dynamics 365 Business Central: Automatically create contacts when creating customers/vendors/bank accounts
     
    Hope this helps.
    Thanks.
    ZHU

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,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans