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.

  • Published 05 Apr 2024
  • 3 mins read
Winter '24: New way to do complex validations in Flows
Table of contents

Hutte Expert Panel

Sushrut Kumar Mishra
Sushrut Kumar Mishra
Salesforce Developer, Technical Writer, and Entrepreneur
Sushrut is a skilled Salesforce Developer, Technical Writer, and Entrepreneur. His expertise includes front-end dev, Web3, and DevRel. He leverages technology to craft exceptional digital experiences.
Manuel Moya
Manuel Moya
Salesforce DevOps Consultant & Application Architect
Manuel Moya Ferrer is a highly skilled freelancer who serves as a technical architect, developer, and DevOps engineer. He specializes in Salesforce solutions, covering all technical aspects of their development lifecycle.
Article Highlights
  • The new Custom Error feature in Salesforce's Flow Builder allows admins to create complex validations similar to Apex triggers but without coding, enhancing data integrity with dynamic error messages.
  • Custom Error actions can be configured to display errors either as pop-ups or inline with the field, ensuring clear communication of validation issues directly where they occur.
  • This feature is particularly useful in scenarios where traditional validation rules fall short, such as validating data across related objects or complex discount structures.

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.

There should not be complex validation Flows. Flows should be simple, easy to read, and maintainable by admins. If the requirements are complex, this logic should be moved to Apex, which is more suitable for scaling, maintaining, and importantly, unit testing.
Manuel Moya
Salesforce DevOps Consultant & Application Architect

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.

Last updated: 10 Jul 2024