Here’s an introduction to the "Remove from Collection" activity.
TABLE OF CONTENTS
- Activity program name
- Description
- Properties
- How to use
1. Activity program name
System.Activities.Statements.RemoveFromCollection
2. Description
This activity removes an item from an existing collection.
Notes:
- Verified on Studio Version: 2.2.0.5
- Terminology and features may vary slightly depending on the version.
3. Properties
Property item | Property name | Input fields | Description |
---|
Misc | TypeArgument | Dropdown selection | Select any data type |
Collection | Enter Value (ICollection<TypeArgument> Type) | Set the collection from which the item will be removed. |
Public | Checkbox | Variables and arguments within the activity are logged to a log file and pushed to the Center. (For more details, refer to "About the 'Public' Property".) |
Result | Enter Value (Boolean Type) | The result after removing an item from the existing data. |
Item | Enter Value (TypeArgument Type) | Set the content to be removed from the collection. |
Display name | AnyString | Reflected as the activity name in the Designer Panel. |
4. How to use
Here’s an example of using the "Remove from Collection" activity to delete a specific item from data stored in a newly created List type.
First, drag and drop "Assign" from System > Primitives into the workflow and place it appropriately.
In the Properties panel, under Misc > To, enter a variable of type List (in this example, "sample"). Then, in the Value field, input the value. (In this example, enter new List(Of String) From {"A", "B", "C"}).
For information on creating variables, refer to "How to create variables".
Next, drag and drop "Remove from Collection" from System > Collection into the workflow and place it appropriately.
In the Properties panel, click on Misc> TypeArgument and select String.
In the Properties panel:
- Under Misc > Collection, input the List<String> variable (in this example, "sample").
- In the Result field, input a Boolean variable (in this example, "result").
- In the Item field, input either a string or a String variable (in this example, the string
"B"
).
To retrieve the values stored in the List<String>, drag and drop "For Each (Collection)" from System > Control Flow into the workflow and place it appropriately.
In the Properties panel, click on Misc > TypeArgument and select String.
Next, in the Properties panel, under Misc > Values, input the List<String> variable (in this example, "sample").
To verify the execution results, add "Write Line" from System > Custom to the workflow and configure the necessary variables.
In this example, enter item as the value.
Click "Home > Run" or press the F5 key to execute the workflow and open the Output panel.
Verify that out of the three data items "A", "B", and "C", the item "B" set in the "Remove from Collection" activity has been removed, and only "A" and "C" are displayed.