Skip to main content

Notifications

Announcements

No record found.

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

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

Posted on by 227
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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans