Skip to main content

Notifications

Community site session details

Community site session details

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

create a Custom API to update Sales Order Status

(1) ShareShare
ReportReport
Posted on by 151
Hi All,

We are using On-Prem Business central.

I want to create a custom API to update status of my sales order header.
I will send below JSON as request body.

{
  "OrderNo" : "10001",
  "Status" : "Open"
}

This API should update the Sales header status of 10001 No.
If anyone have any idea, please share or if you have any code snip you can share.

Thanks for your help.
  • Verified answer
    Sami Ullah Profile Picture
    315 Super User 2025 Season 1 on at
    create a Custom API to update Sales Order Status
    Hi,
    You can use the following link for API authentication:
     
     
    To make an API call in Postman, follow this guide:
    https://yzhums.com/6117/
     
    However, when updating the status, note that this field is read-only in Business Central. You will need to use a codeunit to update the status.
     
    Watch this video to understand how to call a codeunit:
    https://www.youtube.com/watch?v=onZav5n0zqk

    Example Codeunit:
    codeunit 50100 "SalesOrderProcessing"
    {
        Permissions = tabledata "Sales Header" = rimd;
        
        procedure UpdateSalesOrderStatus(orderno: Text[50]; status: Text[50]): Text
        var
            SalesOrder: Record "Sales Header";
        begin
            SalesOrder.Reset();
            SalesOrder.SetRange("Document Type", "Sales Document Type"::Order);
            SalesOrder.SetRange("No.", orderno);
            if SalesOrder.FindFirst() then begin
                case status of
                    'Open':
                        SalesOrder.Status := SalesOrder.Status::Open;
                    'Released':
                        SalesOrder.Status := SalesOrder.Status::Released;
                end;
                SalesOrder.Modify(true);
            end else
                exit('Sales Order not found.');
        end;
    }
    


    Example HTTP API Call
    POST /v2.0/{your tenantID}/Production/ODataV4/SalesOrderProcessing_UpdateSalesOrderStatus
    Host: api.businesscentral.dynamics.com
    Content-Type: application/json
    If-Match: *
    company: 2006d1d5-1a4e-ef11-bfe7-6045bde9c989  // your company ID
    Authorization: Bearer {Provide Token}
    
    {
        "orderno": "S-ORD101001",
        "status": "Released"
    }
    



  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    23,824 Super User 2025 Season 1 on at
    create a Custom API to update Sales Order Status

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,452

#2
YUN ZHU Profile Picture

YUN ZHU 1,313 Super User 2025 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 1,083 Most Valuable Professional

Featured topics

Product updates

Dynamics 365 release plans