I am posting this after seeing the posts in the forum related to “Add to Collection” and printing a list of strings. But somehow I could not get this right. Please suggest where I am wrong.Thank you!
See the pic. I have a JSON and I want to print all the postal code in that in a single line. I have the workflow too in the pic. But printing Str1 always just shows one postal code at a time. I need both like 45343, 45342
The problem is that you’re resetting the list by creating a new one and assigning it to StrListResult every iteration. You should move that above your For Each activity.
Also, you can move the assignment of Str1 below the For Each as well as that only needs to happen once.
@Devarajan_Sundaresan
in your for each block you are initializing the list with new List…
so in the next loop the previous added item is overwritten.
Bring the new List(…) initialization before the loop and control the variable scope as well