How to Display Clean Error Messages in Flow

How to Display Clean Error Messages in Flow

In Salesforce Flow, it’s possible to handle errors using fault paths and display the fault message to users when something goes wrong. However, while this approach helps surface the issue, the message that appears is often long and technical. This makes it difficult for users to understand what actually caused the problem. These messages can include system details, exception codes, and unnecessary text, leaving users unsure of what went wrong or how to fix it. In this post, you’ll find a formula that you can use to display clean error messages in Flow. Although it works in most situations, it’s important to note that it doesn’t (and can’t) cover every possible case.

Formula to Display a Clean Error Message

Here’s a text formula that processes the {!$Flow.FaultMessage} and returns only the actual error message itself.

IF(
CONTAINS({!$Flow.FaultMessage}, "REQUIRED_FIELD_MISSING"),
MID(
{!$Flow.FaultMessage},
FIND("REQUIRED_FIELD_MISSING: ", {!$Flow.FaultMessage}) + LEN("REQUIRED_FIELD_MISSING: "),
FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("REQUIRED_FIELD_MISSING: ", {!$Flow.FaultMessage}) - LEN("REQUIRED_FIELD_MISSING: ")
),
IF(
CONTAINS({!$Flow.FaultMessage}, "FIELD_CUSTOM_VALIDATION_EXCEPTION"),
MID(
{!$Flow.FaultMessage},
FIND("FIELD_CUSTOM_VALIDATION_EXCEPTION: ", {!$Flow.FaultMessage}) + LEN("FIELD_CUSTOM_VALIDATION_EXCEPTION: "),
FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("FIELD_CUSTOM_VALIDATION_EXCEPTION: ", {!$Flow.FaultMessage}) - LEN("FIELD_CUSTOM_VALIDATION_EXCEPTION: ")
),
IF(
CONTAINS({!$Flow.FaultMessage}, "_EXCEPTION"),
MID(
{!$Flow.FaultMessage},
FIND("_EXCEPTION: ", {!$Flow.FaultMessage}) + LEN("_EXCEPTION: "),
FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("_EXCEPTION: ", {!$Flow.FaultMessage}) - LEN("_EXCEPTION: ")
),
{!$Flow.FaultMessage}
)))

To display a clean error message, copy this formula and create a text Formula resource in your Flow. Then, use a Screen or Custom Error element to show the message, depending on the type of Flow you are building.

Examples

Here is a Screen Flow that tries to change the Case Status to Escalated, but a validation rule blocks it.

Screen Flow Failure

Here’s how the error message appears when using the standard {!$Flow.FaultMessage} and the formula above.

Displaying the error message

Here is another example from a Flow that tries to create an Opportunity record with some required fields missing.

Missing required fields

In some situations, a Flow can fail because another Flow fails. For example, this Flow performs a field update that triggers a record triggered Flow, and that Flow fails. As a result, the original Flow also fails. Here is how the error message appears using {!$Flow.FaultMessage} and the formula.

Displaying clean error messages in Flow

Lastly, here is a record-triggered flow that fails. The clean error message is displayed through a Custom Error element.

Display Clean Error Message in Record-Triggered Flow

Summary

Flow errors are part of every admin’s reality, and while it’s possible to capture and display them using the fault message, making them readable is the real challenge. Using the formula above, you can display clean error messages in Flow. It helps simplify the error messages so users can better understand what went wrong. Still, Salesforce errors can vary widely, and not every scenario is covered. If you notice a case that isn’t handled yet or think of a situation that could be added, feel free to suggest it so the formula can continue to evolve and improve.

1 Trackback / Pingback

  1. Display Custom Error Messages in Record-Triggered Flows - Salesforce Time

Leave a Reply

Your email address will not be published.


*