Update Child Records When There is a Change in Parent Record
Record-Triggered Flow in Salesforce is one of the many types of Flows that you can use to automate your business processes. You can trigger the Flow when:
- A record is created
- A record is updated
- A record is created or updated
- A record is deleted
And run the Flow:
- Before the record is saved
- After the record is saved
With record-triggered flows you can potentially avoid writing triggers in some specific scenarios. Now you have the option of meeting complex business requirements without writing a single line of code.
Flow is the future of automation in Salesforce and is becoming increasingly powerful with every release. If you are still using Workflow Rules and/or Process Builders to build new automations in Salesforce, I urge you to switch to flows and avoid incurring technical debt.
Spring ‘21 Release Update – Refer to the Prior Values of the Record That Triggered Your Flow
Now when an object’s record is updated, you can access that record’s earlier values in Salesforce Flow. The ‘$Record__Prior’ global variable contains the record’s values immediately before the Flow was run. You can use these values to check for changes in fields and calculate differences in your flow. This acts as an ‘ISCHANGED’ condition in Process Builder which we have made maximum use of in the past. So now you can take benefit of it in Flow and build logic around it.
For this guide, we will be covering how to use the aforementioned ‘$Record__Prior’ global variable in Salesforce Flow. After going through this guide, within the next 20 minutes, you will learn how to:
- Create a Record-Triggered Flow
- Save & Activate the Screen Flow
- Test the Screen Flow
In this guide, we will be creating a Flow to update all the Contacts’ addresses when the related Account address changes. Earlier it could be done using Process Builder, but now you can incorporate it in your Flows using ‘$Record__Prior’ global variable.
|Liked this guide? We are now offering a complete course (self-paced) on Mastering Salesforce Flows. For more details and free preview please click here.|
References & Useful URLs
- Flow Types – Help Article (10 mins) –
- Refer to the Prior Values of the Record That Triggered Your Flow – Spring ’21 Release Notes Article (5 mins) – https://help.salesforce.com/articleView?id=release-notes.rn_forcecom_flow_fbuilder_prior_values_flow.htm&type=5&release=230
- With so many different automation features in Salesforce like validation rules, workflow rules, process builder, flows, apex triggers, assignment rules, escalation rules, auto-response rules etc., it is important for you to understand the order in which these rules will be executed. To download a infographic on the order in which these rules will be executed, please refer to my another blog post (10 mins) – Order of Execution (Rules, Triggers etc.) in Salesforce & Debug Log