recently I’m facing an unusual error: After each loop in a For Each my variable is set back to its default value although a new value was assigned to it. I would expect the variable to keep the newly assigned value and not go back to default. Am I right?
Unfortunately I’m new to the Community Forum and cannot attach the Workflow File. Following you can see a screenshot with the complete workflow, the variabes and the output.
Thanks in advance!
Welcome to uipath community
hmm… yah it should give us the updated value even in second iteration of for each row loop
but this looks strange
fine lets do one thing use a assign activity before to the FOR EACH ROW loop and make the variable definition like
test = "New Value 123"
and remove the default value in the variable panel and try once pls
–make sure that the variable is set with global scope in the variable panel under scope column (like whole sequence)
This is a scope issue, as Palaniyappan mentions above. Since the variable has the scope of “Assign vairable to Test” sequence it is created when the sequence starts and deleted when the sequence ends. So your value is being created with the default value, set to the new value, and then deleted for each iteration of the loop. Change the scope to a larger scope and the variable will persist with the values it is given (IMO global scope is overkill, I would only use as large a scope as is needed).
Thank you @DanielMitchell, that solved the problem! I wasn’t thinking that the scope of the variable would reset its value. Good to know for the future!
Also thanks to you @Palaniyappan!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.