web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Create a warehouse receipt from a purchase order using the webservice.

(0) ShareShare
ReportReport
Posted on by 27

Within Business Central (v15.2)  you can create a Warehouse Receipt from a purchase order

pastedimage1580899856023v1.png

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?

  • Suggested answer
    l.jensen Profile Picture
    27 on at

    I already figured it out. Turns out there is a handy tool in Business Central called the Event Recorder

    pastedimage1580910863757v1.png

    When I ran that and made the warehouse receipt, I came upon the "Get Source Doc. Inbound" code unit.

    When I call that code unit using the following code it works:

    procedure CreateWarehouseReceipt(no: Code[20])
    var
        purchaseHeader: Record "Purchase Header";
        createSourceDocumentCodeunit: Codeunit "Get Source Doc. Inbound";
    begin
        purchaseHeader.SetFilter("No.", no);
        if purchaseHeader.FindSet() then
            createSourceDocumentCodeunit.CreateFromPurchOrder(purchaseHeader);
    end;

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Thank you for sharing final solution / outcome.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 739 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 462 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 406 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans