Transaction Roll back

Transaction Roll back

  
Is transaction roll back built into outsystems?

Example you have a chain of transactions

START --- Action1 -- Action2 -- Action3 --- Action4 --- END

Now say action1,2,3 transaction was successfully committed to the database, then on Action4, something went wrong - it failed to save a record to the database. In this case would outsystems roll back the transaction for Action1,2,3?

Hi Robert,

While you're editing actions, in the left tree there are 2 built-in-actions: CommitTransaction and AbortTransaction (aka rollback transaction). You can use these actions to explicitly force the commit and/or rollback the changes made in the current transaction.


If the request ends without error, the Platform will implicitly commit your changes, otherwise (unhandled exceptions) it will rollback.


Regards,
João Portela
Sorry, forgot to answer to your scenario.

If you use a CommitTransaction action after action Action3 (after executing Action1, Action2 and Action3) if the Action4 fails and you do not have an error handler, the Platform will rollback the changes made by Action4, and changes made by the previous actions were already committed, so they will prevail.

You may use error handler to catch database errors and decide if you want to rollback (property of the "Error Handler") the changes already made to the database.


Regards,
João Portela
Hi Robert,

Unless you manage the transactions explicitly,  "In Platform Server, a transaction begins when the first database access is made on that request and ends after the rendering of the response." You can read more about Handling Transactions here.

Cheers,
Tiago Simões