How would you design a Record-Triggered Flow that automatically updates related records when an Account's Industry changes, while preventing recursion and unnecessary updates?
1 个回答
Hi @Rakesh Goud You can use an After-Save Record-Triggered Flow to automatically update related records when an Account's Industry changes.
Steps:
- Go to Setup → Flows → New Flow → Record-Triggered Flow.
- Select Account as the object.
- Trigger the Flow when a record is updated.
- Select After Save because we need to update related records.
- Add a Decision element to check whether the Industry has changed.
- Use Update Records to update the related records, such as Contacts, based on the Account Id.
- Save, debug, and activate the Flow.
How to prevent recursion and unnecessary updates:
- Use ISCHANGED(Industry) to run the Flow only when Industry changes.
- Set the entry criteria to run only when the record meets the required conditions.
- Update only related records that actually need changes.
- Avoid updating the same Account again unless required.
- Check whether any other Flows or Apex Triggers could update the Account again.
- Use one Update Records element for matching records instead of updating records individually in a loop.
Real-Time Example:
If an Account's Industry changes from Banking to Healthcare, the Flow can automatically update a custom Industry field on all related Contacts.
Useful Salesforce Documentation:
- Record-Triggered Flows – Trailhead
- Flow Builder – Salesforce Help
- Flow Best Practices – Salesforce Architects
My suggestion: Use an After-Save Flow with change detection and filtered updates. This helps avoid unnecessary execution and reduces the risk of recursion.
Hope this helps!