1

I am deploying a flow using SFDX using metadata format. Here's the relevant package.xml entry:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>My_Flow</members>
        <name>Flow</name>
    </types>
    <version>53.0</version>
</Package>

When deploying this, I get the following error:

Type: Flow Version

Error Message: Required field is missing: name

I'm not sure how to solve this. I tried backing down the API version from 53 to 52, 51, 50, etc. but that just resulted in additional errors.

My sfdx-project.json sourceApiVersion is 52.0 and I'm running the following command to deploy the code:

sfdx force:mdapi:deploy -d deploy -u MyTargetOrg

Note, I have included 3 other flows in the deployment that don't raise an error. Here's the flow that's causing the problem. It may be worth noting this is the only flow in the set that is using Async features:

enter image description here

6
  • what sfdx command are you running? Is your api version 53 in sfdx-project.json? Commented Nov 4, 2021 at 20:23
  • @KrisGoncalves I have updated the question with answers to your questions. Commented Nov 4, 2021 at 21:13
  • 1
    I would update your sfdx-project.json API version to be 53 as the package.xml wouldn't be dictating that. For good measure, you can even pass the api version into your command sfdx force:mdapi:deploy -d directory --apiversion 53.0 -u targetOrg. As you noted, the run async feature is presumably the culprit and it specifically is only available at api 53. Commented Nov 4, 2021 at 21:26
  • Thanks Kris. I did these things (updated API version in file to 53 and specified version in deploy command) and I still have the same error. Commented Nov 4, 2021 at 22:04
  • 2
    How did you end up with this flow metadata file? You say it has an async path but I believe it should have a <pathType>AsyncAfterCommit</pathType> within the <scheduledPath> property (new for API 53). It might be worth retrieving again and making sure it's retrieving with API 53 and then deploying as well? Commented Nov 4, 2021 at 23:48

3 Answers 3

2

There is some problem with sfdx force:source:deploy/retrieve when we indicate concrete
--apiversion from command line. It's better to change sourceApiVersion in sfdx-project.json file.

Example for sfdx-cli 7.114.0 and Flow with Asynchronously path (without any Action):

  1. "sourceApiVersion": "51.0"
    sfdx force:source:retrieve -p force-app\flows\ -a 53.0
    Retrieved metadata:
<scheduledPaths/>
  1. "sourceApiVersion": "53.0"
    sfdx force:source:retrieve -p force-app\flows\
    Retrieved metadata:
<scheduledPaths>
   <pathType>AsyncAfterCommit</pathType>
</scheduledPaths>
  1. "sourceApiVersion": "51.0"
    sfdx force:source:deploy -p force-app\flows\ --apiversion 53.0
    Results:
Error  force-app\sales\flows\FlowApiName.flow-meta.xml
Property 'pathType' not valid in version 51.0 (138:25
ERROR running force:source:deploy:  Deploy failed.

Unfortunately pathType for Run Asynchronously option is not documented in Metadata API: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm

We can find it only in Metadata WSDL (file downloaded from setup).

1
  • changing sourceApiVersion worked for me Commented Apr 19, 2022 at 10:31
1

The answer to this is that you need use API version 53.0 or higher, and you are missing two fields in the scheduledPath block at line 35 in your flow.

Yours looks like this:

        <scheduledPaths>
            <connector>
                <targetReference>Your_Flow_Element</targetReference>
            </connector>
        </scheduledPaths>

But it should look like this:

        <scheduledPaths>
            <name>AsyncStep</name>
            <pathType>AsyncAfterCommit</pathType>
            <connector>
                <targetReference>Your_Flow_Element</targetReference>
            </connector>
        </scheduledPaths>

You need to add a name field (this can be anything you like), and a pathType variable that needs to be set to "AsyncAfterCommit".

The docs for this are here: FlowScheduledPath Metadata Documentation


If you're interested, this is how I worked this out: The first error you had is this: Required field is missing: name

So, the easy answer is to add a <name> field. Since it isn't referenced anywhere else in the file, this can be whatever you like. I set mine to "AsyncStep" like this: <name>AsyncStep</name>

This gets past the first error, but runs into another one: Following required fields needs to be set for ScheduledPath of type null: TimeSource, OffsetUnit, OffsetNumber

Here, you have two options. If the flow is a scheduled flow, you will set the 3 fields mentioned in the error. However, since yours is an asynchronous flow, you will want to make sure the type is not null. From here, if you look at the documentation I linked earlier, you will find a field called "pathType", which has the following description:

The type of scheduled path. null is used for time-triggered and record-triggered paths. The default value is null

  • AsyncAfterCommit —The scheduled path runs asynchronously after a save.

So, as you can see, you can add a "pathType" field with a value of "AsyncAfterCommit" like this: <pathType>AsyncAfterCommit</pathType>.

Note that even if your flow is a record-triggered flow, this scheduled path element is not. It is an async path within that flow.

Adding these two fields will solve your issue as long as your API version is set to at least version 53.0

Hope that helps!

Duncan

2
  • you'd think the MDAPI would retrieve these xml elements at v53+
    – cropredy
    Commented Aug 8, 2022 at 3:30
  • Haha, you would think... Yes.
    – Dunks184
    Commented Aug 10, 2022 at 0:49
0

I had to switch my flows to run immediately from asynchronous, and that allowed the deployment to succeed. Then switch back in prod before activating.

You must log in to answer this question.

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