I have a Process Builder flow set up and I am running some tests around the InvocableMethod Apex code. The tests pass fine in my staging and production environments. Yet, when I try to deploy to production, I get a strange error.

CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow.

Thankfully I received a somewhat more informative error email.

UPSERT FAILED --- ERRORS : (CANNOT_EXECUTE_FLOW_TRIGGER) The record couldn’t be saved because it failed to trigger a flow.
common.exception.AssertionException: ORA-20070: Cannot read from apex_class and apex_trigger while running tests --- for SFDC record with ID : null,

Unfortunately, the deployment has nothing to do with the flow and it is unclear why it is failing. What is the root cause of this error and how can I fix it?


I found out this is a known issue. The other claimed workaround is to deploy via the Metadata API.


Because I was subscribed to the Known Issue, I received the following confirmation this issue is resolved.

We are pleased to notify you that the following Known Issue has been resolved: Executing an InvocableMethod during an apex test run from a change set can cause Errors.

Thank you for being patient while we worked to address this issue. Please feel free to reach out to Customer Support if you have further questions.


Salesforce Success Team

3 Answers 3


I remember reading a post about this being a bug on the Salesforce side. I think the workaround was to deactivate any other Processes that might trigger on other objects during record creation in the test class.


I encountered the same issue as well with a flow against Opportunities. I added an additional condition in the flow to check if a certain text field does not equal to "Test Running". In my test method, I would update the text field of that test record to "Test Running". This allowed me to test the code around the invocable method, but it does not fire the flow actions.


So I found a way to invoke Apex from Process Builder without causing Unit Tests to fail when executed from a Change Set.

  1. Create an Apex Class that implements the Process.Plugin interface.
  2. Create a Autolaunched Flow that calls the plugin, passing variables from Process Builder to Apex.
  3. Launch the flow as the action in your Process Builder.

You must log in to answer this question.

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