Full Rollback in Batch Posting

navuser1navuser1 Member Posts: 1,333
edited 2024-12-30 in NAV Three Tier
Hello,

There is scenario where I make two sales orders during a process, and I have to post them right away. If the system fails to post any of them under any circumstances, I would like it to roll back entirely.

How can I use the Business Central platform (AL Code) to accomplish this?

Please share your knowledge about it.

Kindly, ignore this topic if you have already gone through the same question in the Dynamics 365 Community forum.

Regards,
SB
Now or Never

Answers

  • Developer101Developer101 Member Posts: 568
    I have seen it on Dynamics 365 Community Forum as well. So have you found a solution for it?
    United Kingdom
  • navuser1navuser1 Member Posts: 1,333
    So far, I have not found any solution.
    Now or Never
  • JJMcJJMc Member Posts: 62
    When you call to the posting codeunit to achieve this, you have then posibility of passing a "SuppressCommit" parameter to avoid commit for each recor you pass, and commited at the end.

    This way if any error occurs during the hole process, the rollback do not create, modify, delete, any registers in the database
  • navuser1navuser1 Member Posts: 1,333
    edited 2024-12-31
    Exactly the same approach I have already implemented.

    wbq63wn55xu8.png
    Now or Never
  • Developer101Developer101 Member Posts: 568
    > @navuser1 said:
    > Exactly the same approach I have already implemented.
    Has this worked?
    United Kingdom
  • txerifftxeriff Member Posts: 514
    By Standard the posting routine will commit, I didn't know MS introduced SetSupressCommit function, in the old days we used a blank error to prevent the commit in the code (Error(''))

    My understanding is you have some piece of code (bespoke) that fails sometimes but the document has already been posted. I would review if you have your piece of code in the right place as it should happen before any commits, it would rollback by default.
  • vaprogvaprog Member Posts: 1,148
    SetSupressCommit only supresses any explicit call to Commit during the execution of the Codeunit. This allows you to include more database changes into the same transaction such as updating bookkeeping daten related to some interface to an external system. As such it is very different from Error('')
  • navuser1navuser1 Member Posts: 1,333
    @Developer101
    It seems working fine
    Now or Never
Sign In or Register to comment.