"Add To Collection" Activity

Created by akaBot Support, Modified on Tue, 24 Dec, 2024 at 9:41 AM by akaBot Support

Introduction to the "Add to Collection" Activity


TABLE OF CONTENTS

  1. Activity program name
  2. Description
  3. Properties
  4. Usage


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

Property Category

Property Name

Input Field

Description

Misc

TypeArgument

Dropdown

Select the desired data type.

Collection

Input field (ICollection<T>)

Specify the collection to which the item will be added.

Public

Checkbox

Logs variables and arguments in the activity to the log file and pushes them to Center.

Item

Input field (TypeArgument)

Specify the content to be added to the collection.

Display Name

Input field (String)

Reflected as the activity name in the designer panel.


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

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article