+ Start a Discussion
vineet kumarvineet kumar 

How to show Trigger error message (User friendly message) in a salesforce flow

Getting the following error in flow: 
This error occurred when the flow tried to create records: FIELD_CUSTOM_VALIDATION_EXCEPTION: PO Balance is running low, please select another PO for this invoice. You can look up ExceptionCode values in the SOAP API Developer Guide.

Want to show an actual trigger error message in flow(added in addError at code level).

Any suggestions would be appreciated.
Thanks
AnudeepAnudeep (Salesforce Developers) 
Hi Vineet - Based on this answer, you cannot add errors to records with flow. You can use an Apex trigger and the SObject.addError method to add an error message and prevent the DML from occurring.

However, you can use a flow error screen and add a FaultMessage

User-added image

or add a template like described in the document below

http://https://help.salesforce.com/articleView?id=flow_build_logic_fault_usermsg.htm&type=5

Let me know if this helps

Thanks, 
Anudeep
vineet kumarvineet kumar
@Anudeep  Thanks for your reply.
The solution you have given is being used currently but I just want to show error message.

This is being shown in the flow screen as below

This error occurred when the flow tried to create records: FIELD_CUSTOM_VALIDATION_EXCEPTION: PO Balance is running low, please select another PO for this invoice. You can look up ExceptionCode values in the SOAP API Developer Guide.

I just want to show the error message from the fault message for example error message from above fault message: PO Balance is running low, please select another PO for this invoice.

Not the complete fault message.
Numa RochNuma Roch
Maybe use a formula with operators like SUBSTITUTE, LEFT, RIGHT, LEN etc. or some REGEX, in order to extract the part you want.