Add To Collection

The collection package in the designer acts as a container to store information/data during the
run time. We can use the add to collection activity to dynamically store the data from an excel
file or a web service in a table format.

Technical Reference

 

    

 

     

 

 

 MISC

Collection: This indicates the name of the collection variable to which the item has to be added

Display Name: Displays the name of the activity. You can also customize the activity name to help troubleshoot issues faster. This name will be used for logging purposes.

Item: This indicates the name of the variable which has to be added to the collection

TypeArgument: This indicates the type of the argument which is going to be added. There are number of options from which we can choose.


*Mandatory fields to execute the workflow

Use Case

Here we are going to automate and demonstrate the utilization of Collections feature.
The following activity illustrates on how we are going to add a name to the collection
of lists. Here we add names to the list of strings, so we declare all those names in a 
variable and enter the variable here. 

Variable Creation

1.     From the variable section below, create a variable as “Name” and choose the
variable type as string. Also add a default value to the variable as “John” which
needs to be added to the collection tab in double quotes.

2.   When we use the add to collections activity, create a variable in the variable
box to execute the action.

3.    Create another variable for the collection name for which the item has to be added.

4.    Use “Name_Col” as name of the variable.

5.    In the string type we need to click on Browse types and type
System.Collections.Generic.List<T> in the search option and this gets displayed
as List<String>.

6.    Now choose the default as New list (of string) for the name to be added
to the collection.

Steps to execute the bot

1.     Open a project and create a workflow.

2.     Drag and drop a sequence activity from the ControlFlow feature to the workflow

3.     Double click on the activity.

4.     Create variables for item that is to be added in collection and for the collection activity. 

5.     Drag and drop a write line activity from the primitives feature to the sequence box of
the workflow.

6.     Enter the VB expression as “Initial Value:” +Name_Col.Count.ToString , which
gives an output of what the value was before adding the item to the collection. 

7.    Drag and drop an Add collection activity below this Write line activity and enter
the variables in the property box.

8.    From the properties panel, add “Name_Col” variable in collection tab.

9.   To the Item box add the “Name” variable to add the item to the collection.

10.  In the TypeArgument, we need to choose String from list of drop down as we
are going to add string type to the list.

11.Drag and drop another write line activity Below the Add to Collections activity
which will help us to understand if the value has been added.

12. Enter the VB expression as “Final Value:” +Name_Col.Count.ToString

13.  Set the whole sequence as a start node for this activity and execute the workflow.

The bot executes and adds the name "John" to the collection "Name" and
then writes the count of the variable.