When attempting to deploy a Salesforce flow, you may encounter an error message related to the API version, such as:
Failed to deploy [Flow_Name] with error: The field apiVersion can't be "[API_Version]".
In this example, `[Flow_Name]` would be the name of the flow you are trying to deploy, and `[API_Version]` would be the version number, like "60", that is causing the issue.
Root Cause
This error occurs because the API version specified in the flow is not compatible with the target environment.
Resolution Options
There are two ways to resolve this issue:
Option 1: Modify the Target API Version in Salesforce and Fetch Again
Log in to Salesforce: Navigate to your Salesforce instance and log in.
Find the Flow: Go to `Setup` > `Flows` and locate the problematic flow.
Edit the Flow**: Click to edit it.
Change API Version: Find the `API Version` field and change it to a supported version (e.g., "59" if "60" is unsupported).
Save and Deploy: Save the changes and deploy the updated flow.
Fetch Again: Fetch the updated flow into your local environment.
Option 2: Modify the Property in the NaCl File
Locate the NaCl File as part of your deployment flow and edit the NaCl
Find the API Version: Search for the `apiVersion` property that is causing the issue (e.g., "60").
Change API Version: Modify the `apiVersion` to a supported version (e.g., change from "60" to "59").
Apply and Preview the deployment and check the change you've just made
Deploy (& Push): Save the NaCl file and deploy it to the target environment.
Additional Notes
Always test changes in a sandbox or development environment before deploying to production.
Refer to Salesforce documentation or support for a list of supported API versions.
By following either of these options, you should be able to resolve the API version error and successfully deploy the flow.