As The Salesforce Spring 21 release is almost here, it also includes many other features related to flow. One of them are Get Old Values in Record Triggered Flow. As of now we don’t have any way to get Old Values in Flow. Either we need to go with Process Builder or Use Trigger. But with Salesforce Spring 21 we can get Old Values in Salesforce Flow.
So Today we will check how we can do this with a basic demo where this feature will help us.
Create Record Triggered Flow
Firstly we need to create Record Trigger Flow. So search for Flows and click on New Button. In the next screen we need to select Record-Triggered Flow.
Click on the Start icon and Configure Trigger. Here we need to select A record is updated or the third option. For the Run the Flow you can select any option. I have used Before the record is saved.
Get Old Values in Record Trigger Flow
In Our Demo, We will update the Old Account Name in description Field. So firstly we will check if on record Account Name is changed. For this we will use Decision Component. In the decision component when you will click in resource, you will notice that we now have two variables. One is $Record and second is $Record__Prior.
While the PRIORVALUE() function has its own limitations. $Record__Prior gives us all fields which are related to our record. So this way we can use any fields and not only few selected one. As we need to check Account Name so we will refer that.
In Where to execute Outcome we will select Only if the record that triggered the flow to run is updated to meet the condition requirements.
Update Description Field With Old Values
Now we will Update the description field with the old Account Name. What if, Flow is running on record creation and we try to refer Old value. Do we get exception? Don’t worry in this case we will get blank value and not any exception. So we can also use this to verify if our trigger is running on creation or update. We don’t need to create separate Flows.
As we are using before Save flow so we don’t need the Update action here. So we are done here just save and activate it. and we are ready to test. Below is how our final flow will look like.
As we can see in the demo video we captured the old values in Description. This is a very basic example but we can definitely cover some advance use cases. Now we can get Old Values in Record Triggered Flow and use them to make decision or keep history of fields data.
Check how we can pass Old record values from Flow to Apex here.
Like My Facebook page for more updates.
So do you have any use case where you can use this new feature, let me know in comments. Happy Programming 🙂