Printing a list of Strings

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

Hello Devarajan,

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.

2 Likes

@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

1 Like

Hi @Devarajan_Sundaresan,

Is this what you’re looking for?

1 Like

yeah… What a shame! :frowning: may be 'cos it’s a Friday :slight_smile:

Thank you both @dmccammond, @ppr

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.