Common Salesforce Flow Errors and How to Troubleshoot Them


Copado allows you to customize and extend your DevOps process by triggering Salesforce flows as part of your deployments. When working with flows, you may come across different errors, and although every time a flow interview fails Salesforce sends you an error message, sometimes these messages are not very clear.

In this article you will find information about some common errors and how to troubleshoot them.

Troubleshooting Flow Errors

Salesforce provides a quick and easy way to test your flow and make sure it works as expected before you execute it. This step is highly recommended, as you can review any potential issues and fix them before the flow gets actually executed as part of your processes.
In the flow builder there is a button named Debug on Canvas:

User-added image

Click on it and enter the values of the input variables included in your flow and then run it. Once the execution completes, you can check the Debug Details sections to see if there are any errors:

User-added image

Now let’s go through some of the reasons why you can encounter an error when running a flow.

Flow Permissions

One of the most obvious things to look at is flow permissions. In order for your user to be able to run a flow, it needs certain permissions that can be granted either through the Manage Flow or Run Flows permissions at profile or permission-set level or by checking the Flow User checkbox on the user detail page. For more information about this, take a look at Salesforce’s article How Does Flow Security Work?

Variable Configuration

Another common issue that can lead to flow errors has to do with variables and parameters. Different jobs require different parameters in order to be executed. For example, if you want to check the status of a Copado job, you need two parameters: the Copado backend job Id and the Copado API key. Make sure your flow is not missing any required parameters or variables. Check out Copado’s API documentation for more information about the different parameters each of the Copado webhooks requires.

In addition to this, variables require a specific configuration and your flow may not work if your variables have not  been set up correctly. If you are building a flow that you will run as part of your deployment with Copado, your variables should have the Available for Input checkbox selected:

User-added image

Parsing Exceptions

When you get an error from the external service your flow is calling to, for instance if you don’t provide all the required values that the action the flow is going to trigger requires, you may receive a message similar to this one: “Error Occurred: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]”. Some APIs return an HTML message with the error, and external services cannot parse it, as it can only read json, so you get an exception:

User-added image

To find out what the underlying issue is, review all the variables and make sure they have been correctly configured. You can also use the Debug on Canvas option within the flow builder and check the debug logs in the developer console to see an extended HTML with the details.

Object/Field-Level Security

Flows can be run in user context or system context. When a flow runs in system context, the flow has permission to access and modify all data, while if it runs in user context, the object and field restrictions of the running user will be applied. Let’s say your flow needs to update the Status field on the Copado Result record but your user doesn’t have access to edit that field. If your flow is running in user mode, an error will be returned. How do you know which context your flow is running in? By default, the context in which a flow is run, depends on how the flow is launched, check out Salesforce’s article Which Context Do Flows Run In for more information.

Too Many SOQL Queries

SOQL (Salesforce Object Query Language) allows you to search for information within Salesforce records. In flows, SOQL is mainly used in Update Records or Create Records elements. Let’s say you have triggered a Copado job and a Result record has automatically been created by Copado. Once the job completes, you may want to look for that Result record and get it updated with the job result, and that’s where SOQL comes into play.

Salesforce currently has a limit of 100 SOQL queries per flow execution. If your flow is running a lot of SOQL queries, you may hit governor limits and get a “too many SOQL queries” error. Take a look at this Salesforce article for more information about this error and how to avoid it.
Tip: Add a Pause element (you can resume the flow immediately) before the Update Records element that is throwing the error. The query limit will be reset.

Troubleshooting a Salesforce Flow Deployment Step

If you have included a Salesforce Flow step in your deployment or are triggering a flow as part of your automation and quality process with Copado Continuous Delivery, and the step is stuck as In Progress, check out the following things:

  • The status on the Result record may not have been updated as success or failed after the job execution, hence, the flow step is still in progress. If this is the case, check if your user has edit access on the Status field. 
  • Make sure the step prior to updating the Result record has not failed. If there has been an error in the previous step, you or your admin user should have received an email with the error details.
  • Variable names are case sensitive. Make sure the parameters included in the Salesforce Flow deployment step in Copado match the input variable name in your flow.

How did we do?