web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
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

(1) ShareShare
ReportReport
Posted on by 311
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.
I have the same question (0)

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,651

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 808 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 718 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans