Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Keep Sales Order Open after posting

(4) ShareShare
ReportReport
Posted on by 193
Hello!
 
I was wondering if it is possible to post a Sales Order, but not change the status to 'Released'. I would like to keep the status as 'Open', until it is manually released by pressing the 'Release' button on the Sales Order.
 
How can I achieve this without putting myself in an infinite loop using AL?
  • Hagru Profile Picture
    Hagru 193 on at
    Keep Sales Order Open after posting
    I verified the answer @Khushbu Rajvi. delivered, as that helped me a lot on the way. I mixed this with another trigger in the Sales-Post CodeUnit, and the results are what I was looking for.
     
    Along with a field in the Sales Setup, this is the final code. I am adding it here both for my own future reference, but also for others that may be looking for a similar solution:
     
     
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", OnBeforeFinalizePosting, '', false, false)]
        local procedure KeepSalesOrdersAfterInvoiced(var EverythingInvoiced: Boolean)
        var
            SalesSetup: Record "Sales & Receivables Setup";
        begin
            SalesSetup.FindFirst();
            if SalesSetup.AllowStatusStayOpen then begin
                EverythingInvoiced := false;
            end;
        end;
     
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", OnAfterFinalizePosting, '', false, false)]
        local procedure SetStatusBackToOpen(var SalesHeader: Record "Sales Header")
        var
            SalesSetup: Record "Sales & Receivables Setup";
        begin
            SalesSetup.FindFirst();
            if SalesSetup.AllowStatusStayOpen then begin
                SalesHeader.Status := SalesHeader.Status::Open;
                SalesHeader.Modify();
            end;
        end;
     
    This allows the Sales Order to stay in the list with an Open status, and the user is also allowed to manually Release the Order. 
  • Hagru Profile Picture
    Hagru 193 on at
    Keep Sales Order Open after posting
     
    When a Sales Order is posted, the customer wants to keep the Sales Order in the Sales Order list, and keep the Status as Open. Then, at a point further down, they want to manually Release the order by pressing the "Release" button on the order. 
     
    Everything else should work exactly like it is supposed to when posting an order.
  • Suggested answer
    Valentin Castravet Profile Picture
    Valentin Castravet 25,794 Super User 2025 Season 1 on at
    Keep Sales Order Open after posting
    Can you clarify what you're trying to achieve? There may be standard functionality that can accomplish this without the need for customization.
     
  • Suggested answer
    Jun Wang Profile Picture
    Jun Wang 7,551 Super User 2025 Season 1 on at
    Keep Sales Order Open after posting
    Not sure why you need such behavior. There might be other options if you share the business needs. If you want to control posting a sales order, you could also consider using workflow as well. 
  • Suggested answer
    Ramesh Kumar Profile Picture
    Ramesh Kumar 259 on at
    Keep Sales Order Open after posting
    In standard Business Central, you need to release the order before posting a shipment or invoice. However, this can be achieved through custom code, allowing orders to remain open via a job queue for all invoiced or shipped orders.
     
    If this helped you, please check the box Does this answer your question?
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 77,245 Super User 2025 Season 1 on at
    Keep Sales Order Open after posting
    The system will check the status of the order when posting. If it is not released, it cannot be posted (this is also controlled in Workflow)
    So instead of bypassing this check, you can do the following in AL.
    After the release is successful, find this order, open it, and you're done.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Verified answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 8,131 Super User 2025 Season 1 on at

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans