Q: “How do I back up ALL my Flow Versions, not just the latest/active ones?”
A: Time Travel! Use an older version of Salesforce’s Metadata API to access inactive Flow Versions.
Here’s the basic process:
- Download all Flow Version API Names and their highest Version Numbers
- Use the results from Step 1 to create a package.xml that requests every Flow Version and specifies API version 43.0
- Log in to Workbench, specifying “API Version” as “43.0” on login
- Use Workbench’s “Deploy | Retrieve” command to download all Flow Version XMLs using the package.xml created in Step 2
Detailed Steps:
1] Download all Flow Version API Names and their highest Version Numbers.
If you’re using RazorSQL, you can run a single query:
SELECT Id, ApiName, VersionNumber FROM FlowDefinitionView
If you’re not using RazorSQL, only 200 records can be queried at once. You’ll need to grab ’em in chunks of 200, like this:
1a] SELECT Id, ApiName, VersionNumber FROM FlowDefinitionView ORDER BY Id LIMIT 200
1b] SELECT Id, ApiName, VersionNumber FROM FlowDefinitionView WHERE Id > '[200th ID]'ORDER BY Id LIMIT 200
1c] SELECT Id, ApiName, VersionNumber FROM FlowDefinitionView WHERE Id > '[400th ID]'ORDER BY Id LIMIT 200
1*] [etc]
2] Use the results from step 1 to create a package.xml that looks like this:
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types><members>[FlowApiName1]-1</members><name>Flow</name></types>
<types><members>[FlowApiName1]-2</members><name>Flow</name></types>
<types><members>[FlowApiName1]-[...]</members><name>Flow</name></types>
<types><members>[FlowApiName1]-[Y]</members><name>Flow</name></types>
[...]
<types><members>[FlowApiNameX]-1</members><name>Flow</name></types>
<types><members>[FlowApiNameX]-2</members><name>Flow</name></types>
<types><members>[FlowApiNameX]-[...]</members><name>Flow</name></types>
<types><members>[FlowApiNameX]-[Y]</members><name>Flow</name></types>
<version>43.0</version>
</Package>
. . . where is the number of distinct Flows, and [X] is the number of distinct Flow Versions for a given Flow (this number will vary for each Flow).[Y]
3] Log in to Workbench, specifying “API Version” as “43.0” on login
4] Navigate to Deploy|Retrieve,
- specify the package.xml created in Step 2,
- select “Single Package”, and
- click the Next button.
When the metadata job finishes running, download the Zip file. You’re done!
Big big thanks to
- Gearset’s blog post How Flows and Flow Definitions changed with the Salesforce Metadata API v44 and
- Victor Lockwood’s StackExchange post
for pointing me in the right direction.
I really wanna create a proper app that automates all this work, though I fear that’s a copious free time kinda thing π