How to store value of string variable into array (In a for each row)


I am looping through rows using For Each Row and getting values of each row and storing in a string variable say storeVar, now all the values (each row value) I want to take them in an array of string. Please suggest me the way.

and after this want to remove duplicates from the array,

Thanks in advance,
Mohini Nemade

1 Like

Hi @mohininemade301094

I guess the best option would be to use a List in this case instead of an array. You can add or remove items from a list during runtime and has much better handling than an array. To add items to a list, you can use Add To Collection activity. Another approach is to use the Invoke method to add items to a list.

And to remove duplicates in a list, you can easily use the below command in an assign activity

I have done a sample workflow for you on this. It adds items to a list, removes duplicates and gives out a output.

AddItemsToList.xaml (6.0 KB)

and later if you want to convert the list to an array, you can use:

Let know whether this works out for you.

If it works, please also make sure to mark my answer as the solution too to help others as well :slight_smile:

1 Like

Yes that is working!!
Thank you so much :slight_smile:

Hi, just one thing, it is not removing duplicates!

This command should remove the duplicates. It worked fine in mine…

not working for me, it is giving me duplicates. any other way ?

Is it possible to share your xaml file along with the set of data that you feel it is not removing? I can check it out…

Here it is, (9.9 KB)

HI @mohininemade301094

In your case, you do not need a list to handle the duplicates. It is much more efficient to do it through datatable functions. I have done the change so that you can get rid of all the looping you have. Now it has only 4 or 5 simple steps :slight_smile: (15.1 KB)

It also removes the duplicates.

If this works for you, please make sure to mark this answer as the solution too :slight_smile:

1 Like

Yup! got it, thank you :slight_smile:

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