EP -10 | ROLL BACK RECORDS ELEMENT | LIGHTNING FLOW SERIES

 


Roll Back Records Element

In this blog you will learn what is Roll Back Records Element and what are it's benefits?

You can use it to reverse a transaction to roll back the records created or updated and prevent the Flow from making any further amendments during its course in a fault path. If you do not use this element, even if Flow used to fail, the pending record changes used to get committed to the database which was not ideal. 
Roll-Back Records element gives you the granular control on how the Flow should behave if anything goes wrong along the way. 
E.g. If you have a Screen Flow where a user is required to create a Contact and a then Case to associate with it, should the Case creation fail, the Flow shall roll-back the transaction and does not commit the created Contact. 

Use Case :
Create a Screen Flow and ask the user Company Name, First name and Last name. After that create a lead based on that information and create an event for that lead as well. It looks like a lot of work right?
But that's not all we need to add a Roll Back Record Element in the flow as well because if anything goes wrong these records should be rolled back.

For this example first we will add a Screen Element like below :


After that we have added a created record element to create a new Lead based on these information.
Have a look at the create record element :


After creating the lead now we need to add another Create Record Element to create an Event for the Lead
Have a look :


If you want to learn about how to use Create Record Element you can checkout in the previous Blogs or you can click here to checkout the youtube video.

Now we will add the star of the show which is Roll Back Record Element. Just drag this element to the canvas and this element is very simple. You just have to add Label and Api name for the element and you are good to go.
Have a look :


We now just need to add this element to the fault part. Which means whenever flow will find any fault while running then it will go to the Rollback Element and will start all over again.
Have a look at the flow to have a better understanding :


This is how our flow will look. Here you will see after creating event if there will be any fault then it will go to the rollback record element and then it will go back to the screen.
What is the main benefit?
  1. If we will not add the rollback element our flow will show un an unhandled error.
  2. Because we have added rollback element if it will go to the fault part then it will rollback and the create lead will be rolled bak.
On the other hand if everything goes right we have added a success screen.
Checkout this video to get detail information about the example :


If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks
Let's learn and grow together.
Love and Peace! 🧡

Post a Comment

0 Comments