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...
Suggested Answer

Full Rollback in Batch Posting

(0) ShareShare
ReportReport
Posted on by 1,144
Hello,

make two sales orders during a process, and have to post them right away. If the system fails to post any of them under any circumstances, would like it to roll back entirely.
 
How can use the Business Central platform (AL Code) to accomplish this?

Please share your knowledge about it.

Regards, 
SB
I have the same question (0)
  • Imran K Profile Picture
    29 on at
    Hello, 
    By rolling back sales orders entirely, do you mean you want to deleting sales order as well?
    If a sales order fails to be posted then it write a code to delete it, should be achievable.
     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,579 Super User 2025 Season 2 on at
  • subrata.bauri Profile Picture
    1,144 on at
    Hi Imran,

    Assume that the first Sales Invoice was successfully posted along with the General Journal Entries which were event-dependent. However, it stuck during the second Sales Invoice posting. So, if this occurs, the system should rollback both the original Sales Invoice and the event-dependent journal entries.


     
  • subrata.bauri Profile Picture
    1,144 on at
    Hi Khushbu Rajvi,

    Thanks for your reply.

    The first link is only for manual reversal rather than systematic rollback. Although Marco's response from your second link provided some relief, I am still unable to implement what he said.
     
    Did the following code Marco want to implement ?
       Repeat
    
            try
                SalesPostCodeunit.Run(TempSalesOrderHeader); // Attempt to post Sales Order
            catch
                Error('Error posting Sales Order %1: %2', TempSalesOrderHeader."No.", GetLastErrorText());
                // Raise the error to trigger rollback        
        until
     

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,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans