Loop elements created in Summer ’20 orgs handle the loop iteration automatically and do not require or allow creation of a manual Loop Variable. In metadata, they look like this:
<loops>
<name>testLoopElement1</name>
<label>testLoopElement1</label>
<locationX>177</locationX>
<locationY>235</locationY>
<collectionReference>testCollectionVar1</collectionReference>
<iterationOrder>Asc</iterationOrder>
</loops>
Loop elements in Spring orgs require a manual Loop Variable and refer to it via an element called <assignNextValueToReference>:
<loops>
<name>loopElement1</name>
<label>loopElement1</label>
<locationX>210</locationX>
<locationY>167</locationY>
<assignNextValueToReference>curAccountIterator</assignNextValueToReference>
<collectionReference>curAccountCollection</collectionReference>
<iterationOrder>Asc</iterationOrder>
</loops>
The value of that element should point at a manual variable of the appropriate type. In this example, because the collection reference is a collection of Accounts, the Loop Variable needs to be a single Account variable:
<variables>
<name>curAccountCollection</name>
<dataType>SObject</dataType>
<isCollection>true</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<objectType>Account</objectType>
</variables>
<variables>
<name>curAccountIterator</name>
<dataType>SObject</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<objectType>Account</objectType>
</variables>
It’s possible to take a flow created on a Summer ’20 sandbox and modify it for deployment to a Spring ’20 production org. This involves the following steps:
- On the Summer org, use the Transfer Metadata screen component to download the flow you’ve created.
- Copy the resulting XML into a text editor, and modify it as follows:
- for each Loop element do the following:
- remove all references from other downstream elements to that Loop element. You’re about to change the Loop element and the references will break
- make sure you have a manual variable to represent the loop variable for that Loop.
- paste in the ‘assignNextValueToReference’ element, giving it the name of the manual variable you want to use for your Loop iterator
- for each Loop element do the following:
<assignNextValueToReference>curAccountIterator</assignNextValueToReference>
- Once you’re done with the above steps, you should have a Flow xml file that will deploy into a Spring ’20 org
- Use Transfer Metadata in another flow, this time on the production org. Set it to transferMode=deploy and pass it the modified Flow XML (the easiest way is usually to paste the text into a Text Template)