Within Business Central (v15.2) you can create a Warehouse Receipt from a purchase order
Now I'm looking for a way to do the same thing via the webservice.
I already found https://community.dynamics.com/business/f/dynamics-365-business-central-forum/295784/how-to-create-warehouse-shipment-from-sales-order-via-web-service/850963#850963 but that seems a lot of work for something that already has an action (and associated flows) within Business Central.
I also found the "Whse.-Create Source Document" codeunit, but I cannot figure out how to use this code unit to create a warehouse receipt.
The following code is how i'm trying to get it to work.
procedure CreateWarehouseReceipt(no: Code[20]) var line: Record "Purchase Line"; warehouseReceiptHeader: Record "Warehouse Receipt Header"; createSourceDocumentCodeunit: Codeunit "Whse.-Create Source Document"; begin warehouseReceiptHeader.Init(); warehouseReceiptHeader."No." := ''; warehouseReceiptHeader.Insert(true); line.SetFilter("No.", no); repeat createSourceDocumentCodeunit.CheckIfPurchLine2ReceiptLine(line); createSourceDocumentCodeunit.PurchLine2ReceiptLine(warehouseReceiptHeader, line); until Line.Next() = 0; end;
Am I missing something? What is the correct way to accomplish this task?