Introduction to the "Add to Collection" Activity
TABLE OF CONTENTS
1. Activity program name
System.Activities.Statements.AddToCollection
2. Description
Up to Studio Version 2.0.2.0
Quick Access: Toolbox > Collections > Add to Collection
From Studio Version 2.0.3.0
Quick Access: Toolbox > System > Collections > Add to Collection
This activity is used to add items to an existing collection.
Verified in Studio Version: 2.1.1.2
The wording may vary slightly depending on the version.
3. Properties
4. Usage
The following example demonstrates using the Add to Collection activity to store values in a newly created List and retrieve those values.
Drag and drop the Assign activity from System > Originals to the designer panel.
In the To field under Miscellaneous properties, enter a variable of type List<String> (e.g., test)
Please create test as Variable, Variable type is System.Collections.Generic.Collection<System.String
(Refer to the "Creating Variables" guide for details.)
In the Value field, enter new List(Of String).
Drag and drop the Add to Collection activity from System > Collections to the designer panel.
Click the TypeArgument property under Miscellaneous and select String.
In the Collection field, enter the List<String> variable (e.g., test).
In the Item field, enter a string or a String type variable (e.g., "akaBot").
Drag and drop another Add to Collection activity to the designer panel.
Set the TypeArgument to String.
In the Collection field, enter the List<String> variable (e.g., test).
In the Item field, enter a string or a String type variable (e.g., "Platform").
Drag and drop the For Each activity from System > Control Flow to the designer panel to retrieve the stored values.
Set the TypeArgument property to String.
In the Values field, enter the List<String> variable (e.g., test).
To verify the execution results, drag and drop the Write Line activity from System > Originals to the designer panel and configure the necessary variables.
(In this example, enter item.)
Click Home > Start or press F5 to run the workflow. Open the output panel and verify the results.
Ensure the items "akaBot" and "Platform", set in the Item property of the Add to Collection activity, are displayed.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article