I'm working on a Stateless flow in a Standard Logic app. The flow works like this:
However, I am facing a strange issue. If I have (say) 2 files in the folder, tempFolderId gets populated with a different Guid for each file, that works fine. But when I try to upload the file using tempFolderId, sometimes it uses the correct value of the tempFolderId (mostly when it runs for the first time), at other times, it uses the same value of tempFolderId in both cases (even tempFolderId in the assignment above shows 2 different values each time).
{
"type": "SetVariable",
"description": "declared this as tempFolderId variable was not getting refreshed due to some reason",
"inputs": {
"name": "tempFolderName",
"value": "@variables('tempFolderId')"
},
"runAfter": {
"HTTP-upload_file": [
"SUCCEEDED"
]
}
}
The compose action (where I build up the final payload also contains the same GUID) like this:
[
{
"TempFolderId": "030a9827-c5d2-4892-8c25-f12d7c6ba0a1",
},
{
"TempFolderId": "030a9827-c5d2-4892-8c25-f12d7c6ba0a1",
}
]
A screenshot of the flow is attached (note: the tick mark shows the value is updated correctly each time within the loop, 'X' shows that the updated value is not being passed.
Am I missing something?
Your problem is, you're using a variable to set the GUID and your For each
will be running in parallel, you need to turn that off.
Note: My screenshots are consumption but the premise is the same.
Variables are available globally and because For each
is running in parallel, it's setting it for each concurrent run and therefore, it can be the same when it gets to the step after you set it.
It's a bit tricky but at the end of the day, if you set the concurrency to 1 (as shown) then it will work for you.
Alternatively, don't use a variable, use a Compose
, I believe (90% sure) that too will overcome your issue.