Hello all!
We are using Business Central API for Sales Order lines posting. docs.microsoft.com/.../dynamics_create_salesorderline
When we trying to post line for item which doesn't have enough stock we receive following error:
Exception: Something went wrong, see content for more details: {"error":{"code":"Internal_RecordNotFound","message":"The Sales Line does not exist. Identification fields and values: Document Type='Order',Document No.='1601',Line No.='10000' CorrelationId: 3ef083b4-c7f2-40f6-a109-c86690aecf57."}}
When we try to create exactly same order (with same quantities in line) in Business central it successfully created and just give us a warning about stock.
Can someone suggest us please, how we can avoid this error in API? Or maybe we need to add something into information we posting?
Thanks in advance!
Thanks for your reply Jack!
We use normal MBC API, not our custom AL API Page
Can you tell me please, based on your answer i understand that this is more issue about validation time. But when we do insert in MBC itself (by hands) we don't have any errors at all and line succesfullt created even after validation.
So maybe API has some additional validation steps which not allow us to insert lines without stock? Or we can enable\disable some settings in MBC to use it smae way as it in MBC itself?
This sounds like more a timing issue...(as in the API is creating the sales line and validating the fields without inserting the record (and then a piece of code is looking for that line)). Whereas when you do the same with your fingers in the client one of the controls/ validations of the sales order subpage is inserting the record before the qty is validated.
If you can edit the API page - convert it to source table temporary, and the via the OnInsert/OnModify/... triggers code the creation of the sales lines to insert and then validate your remaining fields...
or
Change you API calls to be a POST simply creating the sales line, and then a second call to PATCH the created sales line with the remaining fields
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156