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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

API Page for Sales Header - problem with defaults

(2) ShareShare
ReportReport
Posted on by 2
I am building a simple API page for Sales Header and need to be able to override the Location Code to the one provided in the request (if provided). So if I send the request like:
 
POST: /salesOrders
{
"sellToCustomerNo": "CustomerA",
"locationCode": "LocationB"
}
 
I want the Location Code on the Sales Order to be set to LocationB. Unfortunately, on the "Sales Header" table, there is a OnInsert trigger that defaults the "Location Code" (in the InitRecord() procedure)... I don't seem to be able to override this in page OnInsertRecord trigger (it's called before the table OnInsert I guess?) - so I'm stuck. I can make another request (PATCH), then it works fine, but I'd like to avoid that as much as possible.
I thought about using IntegrationEvent OnBeforeUpdateLocationCode, but I don't want to modify the standard BC behavior outside of this single API page.
Is there an answer to this? Other than "make a buffer table and insert into it, instead of directly into the Sales Header"?
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    93,325 Super User 2025 Season 2 on at
    API Page for Sales Header - problem with defaults
    Hi, You can skip the code that automatically obtains the Location Code by using the following event.
    OnValidateSellToCustomerNoOnBeforeValidateLocationCode
     
    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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 2,762

#2
Sumit Singh Profile Picture

Sumit Singh 2,573

#3
YUN ZHU Profile Picture

YUN ZHU 1,930 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans