I've created a flow in my sandbox environment and I'm trying to deploy it to the production environment via a change set, but I'm getting the following error:

Required field is missing: assignNextValueToReference

Required field is missing: assignNextValueToReference

I understand from this community topic that this is down to a change in newer Salesforce flows from using a separate loop variable into using an automatic variable:

enter image description here

assignNextValueToReference seems to refer to the old loop variable option, suggesting that the production environment still expects a loop variable, whereas sandbox doesn't even have an option for one anymore

Given that it isn't possible to create an old style loop in the sandbox flow designer, how do I get this deployed to production? The community topic talked about manually editing an XML file, but I don't know how to get to this, and this seems like an error-prone option.

My production environment instance is AP19, which states it is "Spring '20 Patch 23.7", whereas my sandbox environment instance is CS74, which states it is "Summer '20 Patch 7.2". If there isn't a way to deploy this change, how can I fix my environments to be the same?

2 Answers 2


With a tiny bit of help from Salesforce explaining the procedure, I finally have a resolution. I'll document my procedure here.

I've created this sample flow which simply increments the start date for all contracts in the system by one day:

enter image description here

And we have our loop:

enter image description here


Within the .flow definition file (XML), which we'll extract later, we need to create a variable. The easiest way is to actually create the variable within the flow before we start working on the XML. This will save us doing it in XML and prevent us from making mistakes:

enter image description here

Once you've created your loop variable(s), save the flow and activate it.

Next create a file on your computer called package.xml and fill it with the following data:

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

Note: Replace AAADummyFlow with the API name of your flow.

Now head on over to https://workbench.developerforce.com/ and login. This isn't an official Salesforce product, but it seems to be the de facto standard for accessign the Metadata API within the community.

Once you're logged in, navigate to over to Migration > Retrieve. Select your package.xml as the "unpackaged manifest" and then check the "Single package" box:

enter image description here

Click "Next" and then on the next page select "Retrieve". After a while, you'll have the option to "Download ZIP File". Select this.

Download the zip file and extract it somewhere. Your directory should now look like this:

enter image description here

Navigate into the "flows" folder and open your .flow file in your favourite XML-capable editor. Now we want to search for <loops>. There will be a loops entry for each of your loop blocks.

So I'll find the one with <name>Loop_contracts</name> to match the loop block I created. Just under <locationY>....</locationY> we want to reference the loop variable we created, so we'll add this line:


Replace ContractLoopItem with whatever you named your loop variable in the previous step. You should now have something a little bit like this:

enter image description here

We're not quite done yet. We now need to find references to Loop_contracts and replace them with ContractLoopItem. Note that we should only do this for references. We should not update any <connector> references because these are links to the loop block, as opposed to the loop items. So in mine, I have an assignToReference that needs updatingm, and an inputReference that needs updating. We'll replace the Loop_contracts value within these with ContractLoopItem:

enter image description here enter image description here

Now that we've found and replaced all the instances of the loop items, save the file and zip it all back up:

enter image description here

Now head back to Workbench and go to Migration > Deploy. Select the file you just edited, and then check "Rollback on Error" and "Single Package". I recommend deploying this back to your sandbox org first. If you're deploying direct to production, be sure to set test level to something other than "NoTestRun":

enter image description here

Click "Next" and then click "Deploy". If all has gone well you should see Status: Succeded.

enter image description here

Now go back to Flows on Salesforce and you can see we have a third version of our flow now:

enter image description here

We can also wee that the loop now references our variable:

enter image description here


  1. In my own flows I had problems with output variables from subflows. I did not have them assigned to variables, instead letting Salesforce take care of that automatically. This caused problems with things referencing them treating them as if they didn't exist. To solve this I simply explicitly assigned the values to variables.

enter image description here

  1. I highly recommend checking every block that uses the loop item to ensure that everything has been assigned properly. Be sure you test your updated flow before you deploy it to production.

  2. I read somewhere that Mac adds extra things to zip files, which could lead to a message stating that package.xml can't be found. I also found that not selecting "Single Package" led to this.

I hope this helps!

  • Thanks for the very detailed description! I think I'll just wait until Summer 20 release to deploy lol. Jun 24, 2020 at 15:53

I just ran into this issue and was able to resolve it thanks to Vaheh Hartoonian.

Take a look at this thread: https://success.salesforce.com/answers?id=9063A000000lhH7QAI

In particular, the 4th reply which states, in part:

[1] As a workaround, retrieve the flow in the source org. (Summer 20)

[2] Add var_loopVariable to the loop element.

[3] And then add a variable declaration to the flow, For example.

var_loopVariable SObject false false false Account

[4] And redeploy to the source org.

Make sure you read the entire post in the link since it contains additional information.

  • That's actually the post I mentioned in my question. I don't really understand where I'm supposed to add this or how. Jun 9, 2020 at 23:44

You must log in to answer this question.

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