Hi Stefano,
Because we add some UDFs in the sales order header and sales order lines, so I create two pages for deep insert to use one post to create sales order.
Now we use API to get sales order successfully, and when use API to create sales order without line, it works,but when I add sales order lines in the request body, it return "error": {
"code": "Internal_RecordNotFound",
"message": "The Sales Header does not exist. Identification fields and values: Document Type='Quote',No.='EDI1006' CorrelationId: 59ed2b89-e61c-4009-ac73-ad241b42c208."
}
Below is the pages and request body for you reference? Could you please shed me some lights on it?
page 70203543 TRCSalesOrder
{
APIVersion = 'v1.0';
Caption = 'salesOrders', Locked = true;
ChangeTrackingAllowed = true;
DelayedInsert = true;
EntityName = 'salesOrder';
EntitySetName = 'salesOrders';
ODataKeyFields = "No.";
PageType = API;
APIPublisher = 'XXXX';
APIGroup = 'XXX';
SourceTable = "Sales Header";
Extensible = false;
layout
{
area(content)
{
repeater(Group)
{
field(id; Id)
{
ApplicationArea = All;
}
field("documentType"; "Document Type")
{
ApplicationArea = All;
}
field("number"; "No.")
{
ApplicationArea = All;
}
field("orderDate"; "Order Date")
{ ApplicationArea = All; }
field("postingDate"; "Posting Date")
{ ApplicationArea = All; }
field("shipmentDate"; "Shipment Date")
.
.
.
part(salesOrderLines; 70203542)
{
ApplicationArea = All;
Caption = 'Lines', Locked = true;
EntityName = 'salesOrderLine';
EntitySetName = 'salesOrderLines';
SubPageLink = "Document No." = FIELD("No.");
}
}
}
}
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
Insert(true);
exit(false);
end;
trigger OnDeleteRecord(): Boolean
begin
Delete(true);
end;
}
page 70203542 TRCSalesOrderLines
{
Caption = 'SalesLines';
PageType = ListPart;
DelayedInsert = true;
SourceTable = "Sales Line";
layout
{
area(Content)
{
repeater(General)
{
field("documentType"; "Document Type")
{
ApplicationArea = All;
}
field("documentNumber"; "Document No.")
{
ApplicationArea = All;
}
field("lineNumber"; "Line No.")
{
ApplicationArea = All;
}
field("number"; "No.")
{
ApplicationArea = All;
}
field("quantity"; Quantity)
{
ApplicationArea = All;
}
field("unitPrice"; "Unit Price")
{
ApplicationArea = All;
}
}
}
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
Insert(true);
exit(false);
end;
trigger OnDeleteRecord(): Boolean
begin
Delete(true);
end;
}
Request Body
{
"number": "EDI1006",
"sellToCustomerNumber": "10000",
"documentType": "Order",
"orderDate": "2020-08-10",
"postingDate": "2020-08-10",
"shipmentDate": "2020-08-10",
"salesOrderLines": [
{
"number": "1896-S",
"quantity": 2,
"unitPrice": 2
},
{
"number": "1900-S",
"quantity": 2,
"unitPrice": 2
}
]
}