Developers / Admins / Flow

Salesforce Flow: Custom Error Component

By Andreea Doroftei

As the reigning declarative automation tool for Salesforce, Flow is on all Salesforce professionals’ radars nowadays. Be it the need for a visual wizard to support business processes or seamless automations in your Salesforce instance, the numerous Salesforce Flow functionalities have come to the rescue.

Alongside Salesforce’s Winter ’24 release, a few new components will join the club. One of these is the much-needed Custom Error that will surely empower Salesforce Admins to take their data integrity processes to new heights, using out-of-the-box functionality within record-triggered flows.

Cross-Object Validation Rules Without Apex?

That’s right! While it may sound that validation rules will be replaced by this new component, that’s certainly not the case. Validation rules are as useful as ever – as long as your use case is within what the validation rules can do.

So far, if there is a need to loop through related records (e.g. to see if they exist or not, or display an error message to block the deletion of the record in certain situations), a developer would have had to make use of the addError() method in a before save trigger.

Following this release, Salesforce professionals without developer skills will be able to cover these advanced requirements right from a record-triggered flow. This will be possible with a combination of components to narrow the criteria, followed by the new Custom Error component, which can contain one or multiple error messages – everything being available right out of the box.

Custom Error Component in Action

Since existing pre-release orgs have been upgraded to Winter ‘24, and if you already have one from previous releases – make sure to log in and test this component out as well. If not, we will cover a use case below to see the new addition to the Salesforce Flow in action.

The simple use case we’re about to test out is to ensure that upon opportunity creation, no other “New Customer Opportunity” exists on the same account. This will prevent any reporting problems when reporting on brand-new deals versus upsells or expansions. Of course, this can easily be a ‘create or update’ situation depending on the requirement, and in this scenario, the flow is configured for Fast Field Updates.

In a sandbox today, we’d probably use a combination of a roll-up summary field and validation rule to achieve this declaratively. However, what if it wouldn’t be the Opportunity object involved but a custom one with a lookup relationship or no relationship at all? Additionally, what if, instead of checking only the direct account the opportunity belongs to, we would want to check within the entire hierarchy that shares the same “Ultimate Parent”? Let’s take a look at the actual flow!

Note: The tutorials we showcase are built in developer edition orgs with limited data and only a few custom automations. Ensure that you evaluate your existing processes properly before building new ones, including both declarative automations and custom Apex. For Flow specifically, consider the recommended best practices when it comes to the number of record-triggered flows per object.

So, as you noticed in the video, not only can multiple messages be added and customized within the same component, but their position can be also individually selected.

If you need to show the error message simultaneously on two fields and/or the actual window, while the text is different for each of them, you can easily do it.

Summary

All in all, with this new Custom Error component, the possibilities are significantly broader and the solution straightforward – with a possibility to progressively increase the level of complexity.

So, what is the one requirement you will now fulfill with the Custom Error in a flow?

READ MORE: Winter ’24 Treasure Hunt: Preview Orgs Are Live!

The Author

Andreea Doroftei

Andreea is a Salesforce Technical Instructor at Salesforce Ben. She is an 18x certified Salesforce Professional with a passion for User Experience and Automation. 

Leave a Reply