function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sarita Pa 3Sarita Pa 3 

Catch Error in Triger integrated with Flow

Hi All,

I am calling an auto launched Flow from trigger and +ve scenarios are working as expected. Facing an issue with error scenario. I made a field as required and sending empty value which is throwing an error while inserting the record in flow as expected and on the ui i am getting the generic DML exception. I want to over ride that error and display Custom exception. I tried handling with try catch but it is not working as expected.  Does any one has faced this and if any solution let me know.

Thanks for your help with advance.
SwethaSwetha (Salesforce Developers) 
HI Sarita,
Not sure if this is possible through trigger but you might want to create a formula variable in your flow with {!$Flow.FaultMessage}. This will give you the message between the default error message and only show the exception message.

Details of this approach mentioned here : https://salesforce.stackexchange.com/questions/214642/how-to-handle-trigger-error-when-flow-creates-record

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you