System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301R0000000DGbx. Flow error messages: 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. Contact your administrator for help.: []

I am receiving the above error while running a test class which uses only custom metadata and no object . The create user method in a util class where I am creating a test user is failing .

An error occurred at element myRule_1_A1 (FlowActionCall). The flow failed to access the value for myVariable_current.CustomObject__r.Opportunity__r.Id because it hasn't been set or assigned.

P.S . I have checked several similar posts in the Forum which says that the fields used in flow should be set in the test class. But in my case , the objects aren't even used in my test class . The process builder failing runs on a different object.

How should I start solving?

Edit : [ User creation method which is failing]

public static User createUser(String profileName, Boolean isInsert){
    Profile p;

            list<Profile> listProfile = [SELECT Id FROM profile WHERE Name = :profileName];
            if(listProfile.size() > 0) {
            p = listProfile[0];
            } else {
                     return null;

           User testUser = new User(//user fields);
                           insert testUser;


    return testUser;
  • There might be some 'FLOW' or 'PROCESS BUILDER' which is why this exception is coming. Try to check all of them. Especially the one which is provided in the error message.
    – Ruchi
    Commented Sep 27, 2016 at 7:31
  • 1
    If the failure is occurring in the utility class your test method is calling. I suggest you post your test class and utility class. Your utility class needs to be annotated with @isTest unless you have @SeeAllData in your test class enabled.
    – crmprogdev
    Commented Sep 27, 2016 at 13:02
  • @crmprogdev - The utility class is annotated with @ isTest . I have posted the user creation method in the question section. Commented Sep 28, 2016 at 7:37
  • I've been out of pocket for several weeks and hope you've solved this by now. If not, I recommend you add debug statements to your method to see if perhaps your system.assert (or something else) is causing this method to fail.
    – crmprogdev
    Commented Oct 23, 2016 at 13:20
  • This answer can help you pinpoint the flow that's failing salesforce.stackexchange.com/a/174426/31407 Commented May 8, 2020 at 23:12

1 Answer 1


The error is happening in a Flow that was built using Visual Workflow or Process Builder. Unfortunately by default the error reporting from Flows is crap and so you just get a generic message - it wont even tell you which Flow has encountered the error.

You have to identify roughly which Flows you think it might be, and then add error handling to the Flow itself. Error Handling within Flows/Visual Workflow/Process Builder is done via visual components, each Create/Update/Delete step has a 'fault' output from which you can connect an error handler.

e.g. Salesforce recommend adding a 'send email' step to every 'fault' output from every Create/Update/Delete in a flow:

As a best practice, we recommend configuring the fault connectors in your flow so that you always receive an email when a flow fails. In the email, include the current values of all your flow’s resources. The resource values can give you insight into why the flow failed.


Once you've done all that, you should at least then know what the actual problem is (probably a validation error or something like that) and then you can fix it.

  • Couple of additional points - a Flow Trigger is Process Builder though of course the error could be in an autolaunched flow it is calling. It is possible though fiddly to find which flow or PB it is from the id in the email received.
    – Dave Humm
    Commented Sep 8, 2017 at 8:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .