A New Feature Introduced in Salesforce Winter ’24 Release
Salesforce’s Winter ’24 release introduced an exciting new element called “Custom Error” in Record-Triggered Flow. This feature enables you to display custom error messages on the UI, either as a pop-up window or as an inline error on a field. When the message is displayed, the associated record change is rolled back.
Why is this feature valuable?
This feature is particularly useful as it allows you to perform complex validations in Flows, assess the outcomes using the “Decision” element, and then display a “Custom Error” message if the validation fails. Salesforce will automatically roll back changes to the record after displaying the error message. Previously, you would have needed to write an Apex trigger to perform such complex validations.
Example and Business Use Case
In Salesforce, if you have a master-detail relationship between two objects and you delete the master record, Salesforce automatically deletes the child records as well. If you want to prevent the deletion of the master record when child records exist, this previously required writing a trigger.
With the Winter ‘24 release, you can now meet this requirement using the “Custom Error” element. In this guide, we’ll create a Record-Triggered Flow to stop the deletion of a master record when child records exist in a master-detail relationship.