Custom Error in Salesforce flow

In the Salesforce Winter ’24 release, a new feature was introduced in Salesforce Flow. In this blog post, we’ll explore how to use custom errors in Flow.

Use Case

If the opportunity doesn’t have any products added and the stage is marked as “Closed Won,” then a throw error message.

How to Display Custom Message in Flow

Here is the step-by-step guide to display a custom error message in flow.

As per our use case let’s create a record-triggered flow on opportunity.

Next, we need a GET record element to get products associated with the opportunity.

Get Product Related to Opportunity.

Next, add a null check by adding a decision element.

If there are products associated with the opportunity, no error will be thrown. Otherwise, an error message will be triggered. Add custom error element as below.

Next, we need an error message to add. So created a text variable as below.

Next, add the error message in the custom error screen as below. The error message can be thrown at the top of the page or as an inline error on a field.

Now we are done with our flow. Let’s check our final flow.

Conclusion

In this post, we understood how to use custom errors in salesforce flow. If you have any questions related to this feel free to add them in a comment section.

Leave a Comment