Skip to main content
All CollectionsTroubleshootingSalesforce validation errorsSalesforce validation errors
Resolving validation errors - "<xxx> - "apexClass" is invalid. Provide the API name of an Apex class that includes an Apex data type supported in flows."
Resolving validation errors - "<xxx> - "apexClass" is invalid. Provide the API name of an Apex class that includes an Apex data type supported in flows."

Cause and solution to this Salesforce validation error

Michael Krumwiede avatar
Written by Michael Krumwiede
Updated over a week ago

Error overview

When attempting to deploy a Flow that referenced an Apex class from an External service, you might see an error indicating that the referenced Apex class did not exist.

A Salesforce validation error we'd expect you to see, would look as below:
"<xxx> - "apexClass" is invalid. Provide the API name of an Apex class that includes an Apex data type supported in flows."

Note: <xxx> in the above context references a specific Apex class 'name', such as account (Variable), as per below screenshot:

Error explanation

In Salesforce, when deploying components that have dependencies on each other, it is crucial to deploy them in the correct order.

This can become an issue as the Salesforce Metadata API does not deploy components in a specific order. Which means that it may try to deploy the Flow, in this case before the ExternalServiceRegistration. If the Apex class is not already present, the Flow deployment will fail with an error stating that the referenced Apex class does not exist.

This type of error typically arises because the deployment process checks for the existence of all referenced components before completing the deployment. If a referenced component, such as the ExternalService Apex class, is set to be deployed after the Flow, the deployment validation will fail.

Resolution

To resolve this issue, the deployment process needs to be adjusted to ensure that the ExternalServiceRegistration is deployed before the Flow.

Here are the steps to correct the deployment sequence:

1. Deploy the External service registration first:

  • Ensure that the ExternalServiceRegistration that contains this Apex class is deployed and available in the target environment.

  • This step should be done separately to confirm that the Apex class is correctly deployed and recognized by the system.

Note: In Pipelines UI specifically, you can click the Manual resolve button to deploy the required components ahead of the dependency.
โ€‹
You can read more about this feature in our documentation:
โ€‹'Manually resolve' option on Pull Request in the Pipelines UI

2. Deploy the Flow:

  • Once the ExternalServiceRegistration is successfully deployed, proceed with deploying the Flow that references this Apex class.

  • Since the Apex class is now present (in the target environment), the deployment validation will recognize the reference and complete without errors (meaning, validation will succeed).

By following these steps, the deployment can be successfully completed without encountering the validation error related to the non-existent Apex class.

Disclaimer: This error is returned by Salesforce directly, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.

Did this answer your question?