Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Full Rollback in Batch Posting

(1) ShareShare
ReportReport
Posted on by 1,118
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
  • subrata.bauri Profile Picture
    subrata.bauri 1,118 on at
    Full Rollback in Batch Posting
    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
     
  • subrata.bauri Profile Picture
    subrata.bauri 1,118 on at
    Full Rollback in Batch Posting
    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.


     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 5,192 on at
  • Imran K Profile Picture
    Imran K 23 on at
    Full Rollback in Batch Posting
    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.
     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,429 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans