Announcements
We want to build AL API page to POST Return Sales order lines.
We succesfully POST Return Sales Order using API Page for Source table = "Sales header" with document type = "Return order"
But then we try to do POST call with correct Document No(which exists in MBC after first POST call to Sales header API page) and Document Type = "Return order" and receive following error:
{"code":"Internal_InvalidTableRelation","message":"The field Document No. of table Sales Line contains a value (1029) that cannot be found in the related table (Sales Header). CorrelationId: 11a32c7c-6f5e-44da-9f2f-59deeaab9cd3."}}
Our AL Page looks foloowing:
Thanks for your reply.
Actually I created the header first. As you can see in my previous comment, I got the sales invoice number and I just changed it in to "X" in this post manually. Besides this, I checked this sales invoice number on Business Central right after I got this error and the sales invoice header is in there. The most interesting thing is that this issue some times happened on when my program was trying to generate after the first sales invoice line, which mean sometimes I got this error on generating the 10th line, the 20th line or even the 200th line. I used default header page and line page from Business Central (43 - Sales Invoice and 6043 - Sales Document Line Entity).
You API page references sales line, if you are trying to create return order or invoice you need to create the header and then the line.
i have the same error.
error: { "code": "Internal_InvalidTableRelation", "message": "The field Document No. of table Sales Line contains a value (S-INVXXXXX) that cannot be found in the related table (Sales Header). CorrelationId: 4f54d106-d4b5-42ef-9915-01fb91b8826b." }
but my case is little bit different, the issue only happens intermittent. After we re-run the program and it went through. Anyone know what would cause this and how to debug it?
Thanks
Thank you for answer
This did the trick
Thanks again!
Have you tried swapping the parameters round? Following primary key of the table is best. Document Type is before document no. in the case of header and line
André Arnaud de Cal...
294,033
Super User 2025 Season 1
Martin Dráb
232,854
Most Valuable Professional
nmaenpaa
101,158
Moderator