Setting multiple variables in one "Set variable"-action
AnsweredIs it possible to set multiple variables in one action?
I have a case where one variable determines multiple other variables as being the same. Currently I have to do:
If [%variable1] = 4 then Set [%variable2] = 4 Set [%variable3] = 4
Set [%variable4] = 4
Set [%variable5] = 4
Set [%variable6] = 4
Set [%variable7] = 4
Set [%variable8] = 4
Set [%variable9] = 4
Set [%variable10] = 4
End if
...which is 8 actions more than I would like :)
-
Official comment
Hi Philip,
You need a 'Set Variable' action for everytime you wish to set a variable. But, you don't need so many actions. If you have numbers in your variable names, you can do it this way, or you can use a list to loop through your variables.You could make it like this in Foxtrot (explained with 'Foxtrot code' and an image):
If [%variable1] = 4 then
Loop = 9
Set [%Variable[?Add([*CURRENT_LOOP_NUMBER],1)]] = 4
End Loop
End If
Alternatively, you can use a 'VBScript' action to set as many variables as you would like within only one Foxtrot action. Like this, for example:
RPAEngine.SetVar "Variable2", "4"
RPAEngine.SetVar "Variable3", "4"
RPAEngine.SetVar "Variable4", "4"
RPAEngine.SetVar "Variable5", "4"
RPAEngine.SetVar "Variable6", "4"
RPAEngine.SetVar "Variable7", "4"
RPAEngine.SetVar "Variable8", "4"
RPAEngine.SetVar "Variable9", "4"
RPAEngine.SetVar "Variable10", "4"
Comment actions
Please sign in to leave a comment.
Comments
1 comment