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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

(0) ShareShare
ReportReport
Posted on by

Hi!

I would like to know if there is a way to trigger the Posting -> Post -> Ship action (no invoice) for Sales Order using the OData Web Services, SOAP Web Services or API Endpoints

pastedimage1632849270594v1.png

I already saw this bound actions but i would like to make the same without the invoice stuff.

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/resources/dynamics_salesorder#bound-actions

pastedimage1632849644568v2.png

King regards!

I have the same question (0)
  • Verified answer
    Samantha73 Profile Picture
    3,255 on at

    You can copy existing API and create your own. In the new API, comment out below code and create new procedure or rename existing to something like shipOnly(not a requirement just best practise):

       local procedure PostWithShipAndInvoice(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header")

       var

           DummyO365SalesDocument: Record "O365 Sales Document";

           LinesInstructionMgt: Codeunit "Lines Instruction Mgt.";

           O365SendResendInvoice: Codeunit "O365 Send + Resend Invoice";

           OrderNo: Code[20];

           OrderNoSeries: Code[20];

       begin

           O365SendResendInvoice.CheckDocumentIfNoItemsExists(SalesHeader, false, DummyO365SalesDocument);

           LinesInstructionMgt.SalesCheckAllLinesHaveQuantityAssigned(SalesHeader);

           OrderNo := SalesHeader."No.";

           OrderNoSeries := SalesHeader."No. Series";

           SalesHeader.Ship := true;

           //SalesHeader.Invoice := true;//

           SalesHeader.SendToPosting(Codeunit::"Sales-Post");

           SalesInvoiceHeader.SetCurrentKey("Order No.");

           SalesInvoiceHeader.SetRange("Pre-Assigned No. Series", '');

           SalesInvoiceHeader.SetRange("Order No. Series", OrderNoSeries);

           SalesInvoiceHeader.SetRange("Order No.", OrderNo);

           SalesInvoiceHeader.FindFirst();

       end;

    Note: You also need to change few other bits since API looking for created invoice number so find that code but above works as is though u get a error response but order is shiped

    /salesOrders(4bac2cec-1821-ec11-8f46-00224810896b)/Microsoft.NAV.shipOnly

  • jcdlm Profile Picture
    on at

    Hello Samantha,

    Thanks for answering.

    Where did u get that code from?

  • Suggested answer
    jcdlm Profile Picture
    on at

    Finally I solved my problem,

    First of all, I follow this guide to configure AL environment in Visual Studio Code

    docs.microsoft.com/.../devenv-get-started

    Then, downloaded this github repo

    github.com/.../ALAppExtensions

    In the APIV2SalesOrders.Page.al file, I found shipAndInvoice procedure, so I modified it as Samantha said and added the new code to my custom page.

    Then I published as a Web Service and now Im able to trigger this actions using OdataV4

    Hope it helps for someone with same needed.

    Kind regards!

  • Samantha73 Profile Picture
    3,255 on at

    Awesome ...Not a lot of info out there on APIs and some are not there to start with like AP credits...good thing is you can create bound actions or unbound. If performance is key unbound is recommended

  • agaonkar Profile Picture
    25 on at

    Hi there,

    Could you please help me with the request body for the API call

    api.businesscentral.dynamics.com/.../Microsoft.NAV.shipAndInvoice

    Currently I am not supplying anything and it says 

    {
        "error": {
            "code""Application_DialogException",
            "message""Please add at least one line item to the estimate.  CorrelationId:  98d53cd2-b0d3-4962-ab8f-5be785418ff8."
        }
    }
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    You have to supply sales order no. filter within your api to perform the Ship and invoice action.

    Thanks.

  • agaonkar Profile Picture
    25 on at

    I tried the following:

    api.businesscentral.dynamics.com/.../Microsoft.NAV.shipAndInvoice

    where e75cee00-b718-ed11-90eb-000d3a54b3bc is my salesorder id and the request body is

    {

       "number": "S-ORD101011"

    }

    Response is:

    {

       "error": {

           "code": "BadRequest",

           "message": "One or more errors occurred.  CorrelationId:  2a39d66e-3719-4980-be0c-cfcb326dc36c."

       }

    }

    Is there anything wrong?

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Please go through the below link:

    community.dynamics.com/.../posting-invoices-using-apis

  • agaonkar Profile Picture
    25 on at

    Thanks for the link. But I am not able to understand anything.

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Please go through the link and try to understand the process.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans