7

While working on a Flow implementation, one can create multiple versions of it.

Let's say I have my first release ready, Flow's name is "TestFlow". I'm retrieving it with the following command: sfdx force:source:retrieve -m Flow:TestFlow

What I receive is obviously the metadata of the Flow:

<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>53.0</apiVersion>
    <interviewLabel>TestFlow {!$Flow.CurrentDateTime}</interviewLabel>
    <label>TestFlow</label>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>CanvasMode</name>
        <value>
            <stringValue>FREE_FORM_CANVAS</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>OriginBuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processType>Flow</processType>
    <screens>
        <name>Hello</name>
        <label>Hello!</label>
        <locationX>176</locationX>
        <locationY>224</locationY>
        <allowBack>true</allowBack>
        <allowFinish>true</allowFinish>
        <allowPause>true</allowPause>
        <showFooter>true</showFooter>
        <showHeader>true</showHeader>
    </screens>
    <start>
        <locationX>50</locationX>
        <locationY>50</locationY>
        <connector>
            <targetReference>Hello</targetReference>
        </connector>
    </start>
    <status>Active</status>
</Flow>

But it turned out that the implementation needs some changes. Created my second version. One sfdx force:source:retrieve -m Flow:TestFlow later and here it goes - additional <screen> added:

<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>53.0</apiVersion>
    <interviewLabel>TestFlow {!$Flow.CurrentDateTime}</interviewLabel>
    <label>TestFlow</label>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>CanvasMode</name>
        <value>
            <stringValue>FREE_FORM_CANVAS</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>OriginBuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processType>Flow</processType>
    <screens>
        <name>Hello</name>
        <label>Hello!</label>
        <locationX>176</locationX>
        <locationY>224</locationY>
        <allowBack>true</allowBack>
        <allowFinish>true</allowFinish>
        <allowPause>true</allowPause>
        <connector>
            <targetReference>Hello2</targetReference>
        </connector>
        <showFooter>true</showFooter>
        <showHeader>true</showHeader>
    </screens>
    <screens>
        <name>Hello2</name>
        <label>Hello2!</label>
        <locationX>177</locationX>
        <locationY>370</locationY>
        <allowBack>true</allowBack>
        <allowFinish>true</allowFinish>
        <allowPause>true</allowPause>
        <showFooter>true</showFooter>
        <showHeader>true</showHeader>
    </screens>
    <start>
        <locationX>50</locationX>
        <locationY>50</locationY>
        <connector>
            <targetReference>Hello</targetReference>
        </connector>
    </start>
    <status>Obsolete</status>
</Flow>

But! It turned out that I don't like the second version and I reactivated the first one. But what does the sfdx force:source:retrieve -m Flow:TestFlow command retrieve now? Still the second version. In fact, I need to delete it to be able to retrieve the previous version of the Flow again.

Is there any known workaround to this problem other than deleting unused Flow versions with the higher number than the active one?

1 Answer 1

15

Ok, found the solution. The Flow Metadata Documentation says:

To deploy or retrieve a version, you can specify the version number. For example, sampleFlow-3 specifies version 3 of the flow whose unique name is sampleFlow. If you don’t specify a version number, the flow is the latest version.

Accordingly sfdx force:source:retrieve -m Flow:TestFlow-1 will retrieve the first version.

There's one thing to have in mind: If, for instance, version number '3' is the newest one, sfdx force:source:retrieve -m Flow:TestFlow-3 won't retrieve the TestFlow-3.flow-meta.xml, but TestFlow.flow-meta.xml (without the number).

1
  • unfortunately when I retrieve with flow version using your command, it creates a new flow with the version number for me :(
    – vanessen
    Commented Dec 21, 2022 at 7:36

You must log in to answer this question.

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