34
Views
3
Comments
Exception Handler
Application Type
Traditional Web, Mobile, Reactive, Service


What will happen here, i have 2 server actions, as shown in the screen shot.

1] Customer save: here save the customer details in the database. I am not managing transactions explicitly through the CommitTransaction and AbortTransaction actions.

2] Order Save: In this action, I got the database exception, which I caught in the parent action. Here on the datasbe exception handler, the abort transaction property set to no.

As per my understanding, it won't rollback the transaction, which means customer data won't be rolled back. 

What about order data? Will it roll back the transaction from the order table or not? 

Imagine I call this savedata() parent action on the button click client action. The button-click action is completed here.

Will it roll back both transactions? 

Will it roll back from the 1st action only, or will it roll back from the 2nd action only? 

Will it commit all transactions from both actions? 

or is there any other possibility? 

2019-09-17 11-09-41
Miguel Guerreiro

Hi Pradip.

It would be nice if you have shared the content of the CustomerSave and OrderSave server actions.

I understood from your explanation that you're not handling exceptions inside of CustomerSave server action neither inside of OrderSave. Also, you asked what happens when you call SaveData in a button. Correct me if I'm wrong.

If you get an exception in the OrderSave and since CustomerSave was executed correctly, customer data won't be rolled back. Order data can or cannot be rolled back, depending what you have inside that server action. If you have only 1 CreateOrUpdateOrder (for instance), it will be fully rolled back. If you have 3 CreateOrUpdates and the exception was only raised in the third CreateOrUpdate, then it's only rolled back the third CreateOrUpdate.

With regards to the button, the result is the same as described before because you're running the code in the same transaction. Your button will have an action with a Start and an End. The transaction will be running between those elements, regardless you have more actions inside of it. 

If you put a CommitTransaction somewhere in your code, that action will commit the previous database changes and "create" a new transaction. If you don't put a CommitTransaction, a CommitTransaction will be done in the "End" element of your button's action which handles the click event.

I hope I could help you.

Best Regards,

Miguel

2024-12-02 13-16-47
Vipin Yadav

Hi @Pradip Chavhan ,

1. Customer save - The customer data will not be rolled back Because the abort transaction is set No

2. Order Save: The order data was not created because an error occurred during this action. 

I hope this revision is helpful to you! 

Thanks,

Vipin Yadav

2022-05-18 07-58-50
Pradip Chavhan

Thanks both of you for your valuable reply.

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