[SalesForce] any way to handle validation rule errors nicely in flows

When working with a visual flow, it seems that when you get an error saving a record because of a validation rule, that the only error Salesforce will give you is:

An unhandled fault has occurred in this flow

An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

It does send you an email containing more precise details about the error but your user won't know what's going on or what he did wrong.

Is there any way of showing the exact error in the flow to the user? So a solution that would always work and throw a nice message, even when new validation rules or maybe even validations coming from triggers are introduced.

I'm not in favor of having the same validation logic in both the validation rules and the flow itself.

Best Answer

You can assign a fault connector and screen to any lookup or DML action. This should capture a validation rule...although I'm not sure if it will on update of a child causing a validation rule on the parent.

All you need to do is create a screen with a text output that uses the merge field {!$Flow.FaultMessage}:

enter image description here

Then connect the action element to the screen - to do this your element needs to be connected to something else first, the second connection will be for the fault. If it is your last element drag to the fault screen twice then select the connection and press delete. You should be left with the fault line. Below is from a record create, but it could be a record update, lookup or delete:

enter image description here

Related Topic