Converting String to Array inside for loop

Hi,

i am trying to create a array from string collected in web, using the Get text activity inside a for loop. each time when the for loop iterates, the text is stored into some output variable and added to array using “Add to collection”.
when i try to print the final array variable, it always gives only the last value which is collected on the last loop

attached the test file

test.xaml (12.0 KB)

i even tried assigning the below, which resulted in the same output

arrvalue=strValue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

Please advice, where is the mistake or is there any other way to do this!!!

Thanks!
Deena

1 Like

Try this
test (1).xaml (9.7 KB)

Everything was okay with your workflow except the declaration of the ‘items’ array which you had done inside the for each activity.

1 Like

It is because you have initialized the List inside the loop , so every time the loop iterates the List will be initialized and the previous value will be cleared from the collection.

Place the List initialization before the starting the For loop.

Regards,
Ranjith.

1 Like

Thanks @ranjith @siddharth, it works :wink: