Hey, new UiPath learner here.
I am trying to save some values into a string that I extracted from a complex json object and paired using a for loop. No matter what I try, how many variable scopes I change, the output outside of the loop is always the last iteration, I can’t seem to append the results into one string.


The log activity printing finalOutput outputs exactly what I need with each iteration. All I want is to have all these outputs stored in one string variable. Scope of these variables has been changed accordingly.
Hi @michal.gozdzikiewicz,
At the time of every iteration (loop) the data stored in the variable are over-write with the new value. Hence the resulting, last loop value are stored in the variable.
To hold multiple values, you should use Non-Primitive data types such as List, Hash-Set, Dictionary or Data Table.
I suggest you to store the data in DataTable data type so that it is easy accessible to you.
Solution:
-
Use Build Data Table activity with 2 columns and create Data Table variable [before the loop]
-
Inside the loop use Add Data Row to save all the result inside the loop.
Code
{labelsTest, valuesTest}
Your process logic look like
This will help you to hold all the data after execution of the loop.
Thanks