Winter '24: New way to do complex validations in Flows

Arriving in Salesforce’s Winter ‘24 release, Salesforce has shipped a new feature called Custom Error for Flow Builder that can be used to throw custom errors. This has been one of the most awaited and requested features ever since record-triggered Flows were announced.

Winter '24: New way to do complex validations in Flows
Table of contents

What is a Custom Error Message?

Traditionally, to execute complex validations, Developers use Apex triggers. However, with the new Custom Error action, Admins can build complex validations and surface meaningful errors like Apex triggers.

The error messages thrown by the Custom Error action are displayed in a popup window on the “Record” page or as an inline error on a specific field, depending on how the action is configured.

You can also configure this action to throw multiple errors by using just one action within which you can specify numerous errors.

Where would I use this feature?

You’d use this feature to do data validations in your Salesforce org like you use validation rules.

But this only applies to use cases that validation rules can’t achieve. Some of them include scenarios like:

  • Doing validations based on data available on related child objects’ records. For example, if you want to prevent the deactivation of an account if the account has any open cases.
  • Validating complex discounts based on region, quantity, previous orders, product bundles, etc.
  • Providing record ownership-related validations.
  • Throwing multiple meaningful errors for blank inputs on record creations and updates.
  • Forcing a transaction to fail to roll back the changes.

How do you configure the Custom Error action?

The action comes with a simple set of inputs for its configuration.

Custom Error Message

Use this input to specify the message to display to the user. You can also use Flow resources to create a more dynamic Error Message.

Where to Show the Error Message

This radio-type input allows you to configure how you want to surface the error on the UI.

Add Error Message

This button will enable you to add multiple errors within the same action.

Keep your data error-free

Custom Error will be a game-changer, and we encourage you to use it in your Flows to keep your data clean.