Understanding Custom Error Messages in Record-Triggered Flows
With the Winter '24 release, Salesforce introduced the Custom Error element, allowing you to create custom error messages in record-triggered flows. This eliminates the need for cryptic system-generated error messages and provides clear, actionable feedback to users.
Causes for Needing Custom Error Messages
- System-generated errors are unclear: Traditional flow errors present cryptic error messages that don't always make sense regarding the issue
- User experience issues: Regular users typically forward screenshots of errors to Salesforce admins for investigation
- Limited options before Winter '24: Prior to this feature, displaying custom error messages required workarounds like creating checkbox fields and validation rules
- Complex validation requirements: Before-save flows can now directly display error messages for conditions like closing a case without associated files
How to Implement Custom Error Messages
Step 1: Access the Custom Error Element In Flow Builder, find the Custom Error element in the toolbox and drag it onto the canvas where you want to handle the error.
Step 2: Configure Error Messages
-
Use the
{!$Flow.FaultMessage}
variable to display the actual error message that caused the flow to fail -
Add the Custom Error element and use
{!$Flow.FaultMessage}
as the error message, or display a custom message
Step 3: Add Fault Paths Add fault paths to all elements that may fail, such as Update Records or Create Records elements.
Step 4: Set Field-Specific Errors If you know the main reason for failure, you can display the message as an inline error on a specific field.
Key Limitations and Considerations
- The error message field has a 255-character limit
- You can only add one error message per page and one error message per field
- You will still receive the flow error email from Salesforce
- The associated record change is rolled back when an error occurs
Conclusion
The Custom Error element is a very useful feature that solves many problems admins had for a while and is a game changer. It simplifies error handling, provides clearer user feedback, and eliminates the need for complex workarounds.