If I set a variable with a value within a loop and then turn on concurrency - will it be thread safe?
Or can one thread change the value of the variable which will affect another thread?
Is there a recommendation to avoid concurrency when we set variables within the loop? Is there any workaround?
Hello @Kran ,
if you use variable in a parallel loop, all the parallel runs will access it at the same time. It's ok if you only read the variable, but if you also update it, it'll be a mess.
If it's possible, you can use a 'Compose' action instead of a variable, each parallel branch will have its own 'Compose' action with its own input/output.
@tom_rihaThanks for your reply! That was very good information!
But how can I set a variable inside a compose action?
In my situation, as of now, I have a SWITCH case, where I for each of the cases, set a variable which is then used to set a column on a new record.
Do you see anyway to solve this with a compose action? Thanks!
thanks for your reply!
So that If statement checks whether the first condition is empty? And if is, then it checks next one?
Hi @Kran ,
Please use switch conditions in your If expression .
Flow needs to know which compose action to use .
Best Regards,
Wearsky
Hello @Kran ,
I was thinking about the problem and I wrote a blog post with my solution: https://tomriha.com/using-variable-in-a-parallel-loop-in-power-automate-flow/.
Use an array variable, instead of the 'Set variable' use 'Append to array variable' while including some unique identifier of each item + the corresponding value. Filter only the corresponding value from the array and use it in the 'Add row...' action.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
30 | |
29 | |
29 | |
20 | |
11 |