Skip to main content

Notifications

Announcements

No record found.

Business Central forum

Creating a custom API to allow custom field in Sales Lines table to be written to through API

Posted on by 188
Hello!
 
The reason I am writing this post, is because this is my first time creating a custom API bit to Business Central, and I would just like to know if I am doing it right, and if there is something I am missing.
 
I have recently started trying to create a custom API to Business Central, as I want a third party company to be able to write to a custom field I made in the Sales Line table.
The company I work for is using a webshop to sell some items, and the webshop is creating Sales Orders and Sales Lines through an API. That works perfectly with the standard API, however, like I said, I want them to also be able to write to a custom field. 
 
I have followed a couple guides, that I know usually gets posted in response to these kind of questions, the Kauffmann Extending Standard APIs guides, but I am still not quite sure if I did it correctly, so I am describing the process I did below:
 
- Made two tableextensions, one for Sales Lines, and one for Sales Invoice Line Aggregate, which is the buffer table in this case I suppose.
- Added the custom field to both of the tableextensions. (Just a normal field with an ID, Name and Type, plus a Caption inside).
- Downloaded the API code from the repo, found the "APIV2 - Sales Order" and "APIV2 - Sales Order Lines" files, copied them into my project, changed their names and IDs to fit my project, and added APIGroup and APIPublisher to them both.
- Added a dependency to the API in my app.json file, and downloaded symbols, this removed all errors.
- Added the custom field to my Sales Order Lines API page with an OnValidate trigger containing a RegisterFieldSet function.
- Changed the SalesOrderLines part in the Sales Order API page I copied to match my new custom Sales Order Lines API page.
 
Does this sound right? Again - the only thing I want, is to allow them to write to a custom field in the Sales Lines table through the API. The other stuff with creating Sales Orders and Sales Lines and writing to the standard fields is already good.
Categories:

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,835 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans