62
Views
5
Comments
How do Include rollback transaction and commit transaction in a loop

I'm including a value list in this server action CREATE.

How do to rollback, when for example occur wrong in the inclusion seventh register  ?

Because, in this case I need cancel commit until the sixth included register.

This table will receive in the max 10 register each time.


Product.png
2025-12-04 09-01-03
Kiet Phan
Champion

Its automatically rollback for you if there is exception happened.

2025-04-17 05-42-16
Ajit Kurane

Hi Vivian,

Hope you are doing well.

There is one property for the exceptional handler. If you set it to yes then it will rollback the changes automatically.
Please find the below snapshot.

Thanks.

2019-01-07 16-04-16
Siya
Ā 
MVP

btw its never a good idea to invoke database operations in a loop. Do consider using Bulk Insert forge component.

2024-03-23 18-16-49
Bryan Villalobos

Hi @Vivian Mattos ,

As the previous answers mentioned, the transaction that creates the first 6 products should automatically undergo a rollback process due to the default behavior of the Exception Handler where the property Abort Transaction is set to Yes. 

If you are asking this question because it does not rollback the changes, then you may have set the Abort Transaction to False. You can set this back to True. 

Otherwise, there might be some logic that commits the transaction explicitly inside your Product_Create. It could be that you are calling CommitTransaction inside that action or you are calling a service action/Rest inside. 

Have a look and check if that might be the case.


Regards,

Bryan

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

Hi Vivian,

In to what is already shared by others, an action either gets committed or is completely rollback on exception by default, you can find more information about handling transactions in OutSystems here:

Furthermore there are two platform server actions you can use to customize the behaviour but explicitly committing or aborting transactions in your server action:

Regards,

Daniel

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.