You need to sign in to do that
Don't have an account?
SalesRed
Test Class Error: CANNOT_EXECUTE_FLOW_TRIGGER
Hi, I receive the following error in a test class but have not been able to repeat them in non test running scenarios.
"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 301O00000008hM6.
Contact your administrator for help.: []"
Does anyone know if there could be an issue running flows in test class contexts but not otherwise?
Thanks.
"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 301O00000008hM6.
Contact your administrator for help.: []"
Does anyone know if there could be an issue running flows in test class contexts but not otherwise?
Thanks.
Check the below link, might help in this scenario
https://success.salesforce.com/issues_view?id=a1p30000000T3sCAAS
Regards
Siva.
System.DmlException: Update failed. First exception on row 0 with id a0VA0000008l18nMAA; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. <br>A flow trigger failed to execute the flow with version ID 301A0000000CbpA. <br/> Contact your administrator for help.: []
User usr1 = TestUtilClass.insertUser();
system.runAs(usr1){
//put your test code here
}
This should fixed the issue.
Isn't the default running user is my admin user?
Profile profile = [Select Id From Profile where Name = 'System Administrator' limit 1];
User usr1= new User();
usr1.ProfileID = profile.Id;
//all other required field.
insert usr1;
System.runAs(usr1){
}
Thank you.
You might get this error if the SObject (that you're inserting in Test class) has an active Process Builder that expects certain fields to have values and those field values are NOT supplied in the test data before inserting them.
Try to pack all the necessary fields for the SObject that are required by process builder. You don't need to deactivate the process builder to run test successfully.
If you have record types set for that SObject make sure you supply the appropriate record type in the test data preperation as well.
To find the flow (by version ID) which causes the problem, you can use workbench (workbench.developerforce.com).
Goto Workbench > Utilities > REST Explorer > Execute a GET request with this path (/services/data/v41.0/tooling/sobjects/flow/{FlowVersionId})
So, I got an email whenever any process fails.When i debug these email's process are failed due to various reasons.
I Inspected my logs step-by-step then I found my problem is triggers are running multiple times.
So, I hit exceptions like 101 SOQL, CPU time Limit.
By using Static variable's, I restricted my classes to run only one time in a single transaction.
Still, if you face these error's check your process if it has many conditions & If it has criteria like Created & everytime edited then it takes so much to execute.My suggestion is to simply process like run only with specific record types & custom criteria
In my case, some of the fields were missing in the test class itself which were used in Flow and setting those values resolved the issue.