I've run into an issue with my custom Sales Header API page.
When I create a Sales Order by sending a POST request through Postman, everything is inserted correctly except for the Order Date. Regardless of the value I send in the request body, the Order Date is always changed to the current Work Date.
After several hours of trying, I managed to narrow the issue down to the standard Sales Header table. the Init() procedure sets the Order Date to the current Work Date from my understanding.
I continued debugging and found that this appears to be related to the API page's DelayedInsert = true property. With DelayedInsert = true, the Order Date is always initialized to the Work Date before my value is applied. I don't fully understand the logic behind this, but removing DelayedInsert isn't possible on a custom API page.
As a test, I changed the page from PageType = API to PageType = Document, removed DelayedInsert, published the document page as a web service, and the issue was solved, the Order Date from my request was inserted correctly. this confirms the issue, but using a document page exposed as an OData web service isn't the solution I want.
Has anyone encountered this before? Is there a recommended way to work around this while still using a custom API page? Or is my only real option to move away from API pages and implement something like a SOAP/codeunit or another custom endpoint where I have full control over the insertion process?
I'd prefer to keep this as an API page if there's anything I'm overlooking.

Report
All responses (
Answers (