Instead of Add to Collection

I need to create List(of string) in loop. But with Append item to collection I only get an empty list. I output the list with string.format(", ",mylist). If I specify a new list in the Output field, it outputs only the last item. How to correctly create a list and output it on screen using Append item to collection. I haven’t done the loop in the picture yet, because I don’t get the elements out without it.

Hi @Laura_Ringiene ,

Have you tried providing the list variable in the Result property of the activity and checked ?

1 Like

Hi @Laura_Ringiene

You haven’t created variable in the result

Create one there and use that in the string.Join

Regards
Sudharsan

1 Like

We would use
String.Join(", ", sarasas) and not String.Format

3 Likes

prr thank you. With string.join i output, but after the loop, only the last entry in the list is displayed. The DB is a table of 4 rows

have a look here:

sarasas was used as there are all items appended

@Laura_Ringiene ,

Apologies for the wrong suggestion, As the Activities got updated I did think that we would need to provide a resultant list as well in the Activity.

Kindly follow @ppr 's suggestion

But I have saved the collection to the output result myList, so Log Message is what I am referring to. If I specify String.Join(", “,”, sarasas) it outputs an empty string

I got empty line

My Items
image

lets do one by one:

here we can refer to the collection (sarasas) and the item to append as mentioned

But in UiPath.System.Activities 22.10.1 we have some new feature as type argument is auto retrieved from the collection variable datatype
grafik

with the downgrade e.g. to 22.4.5 we get the old behaviour
grafik

In newer versions of UiPath we do have the UI as in your screenshots, i will come back to this soon.

@Laura_Ringiene Let us know which Version of UiPath.System.Activities is used in your project. Thanks

In my project
image

Ok thanks.

Kindly note we also can do the List construction in a single assign activity

Assign Activity
sarasas | List(Of String) =
DB.AsEnumerable.Select(Function (x) x(0).toString.Trim).ToList

1 Like

Hello @Laura_Ringiene

Please check the below video.

Thanks

1 Like

It’s work. Thank you @ppr

Thank you @Rahul_Unnikrishnan

Hello @Laura_Ringiene
Use the same variables in Collection and Output properties.
image
image

Perfect, so feel free to close the topic by
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

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