Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Adding contact to 'company' contact via API

Posted on by 25
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.
 
 
Categories:
  • Verified answer
    IH-07071528-0 Profile Picture
    IH-07071528-0 25 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 8,662 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 68,480 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

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,263 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,112 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans