Break

Estimated reading: 3 minutes 1468 views

This activity assists the user in exiting the loop during execution when utilized in For Each activity.  

Properties

MISC

DisplayName: Displays the name of the activity. The activity name can be customized, which aids in troubleshooting.

Version: It indicates the version of the feature being used.

Example

Here’s an example of how the “Break” activity is used in the workflow –

In the following example, I have a sample excel sheet of employee details, where it contains the employee’s name, mail id and login name. Here I am going to iterate the “EmployeeName” to check the duplicates by using break activity.

Steps to execute the bot:

1. Create a new solution or open an existing workflow.
2. Drag and drop the “ExcelScope” activity from the “ExcelAutomation”.
a. Here I am using this activity to read and extract the values from the Excel sheet.
b. Choose the specified “FilePath” where the excel has been stored.
3. Next, place the “ReadRanges” activity from the Excel Automation feature within the scope.
a. We are using this activity to read the ranges from the provided “Excel” file and extract the data to “Datatable” type as output.
b. Enter the “Range” as “A1” as we are reading the ranges from “A1” to the end of the data.
4. Provide the “SheetName” as it contains the data that needs to be read.
5. Navigate to the properties and create a variable in the “DataTable” field as “EmployeeName”. It will convert and extract the read data to store in the variable “EmployeeName”,
6. There are two ways to create a variable-
7. Now, placing the “ForEach” activity from the “Primitives” to iterate and loop the names from the variable.
a. Here I am providing the “In” variable as the “EmployeeName.Asenumerable()”.
b. Here Choosing the type argument as “system.Data.Datarow”.
8. Inside the ForEach activity, use an If activity to check for duplicate names.

In the Condition field, enter the logic DuplicateList.Contains(CurrentRow(“EmployeeName”).ToString.Trim) Where DuplicateList is a list created to track duplicate names.
9. Inside the If condition:
a. If the condition is True, drag and drop the Break activity. This will stop further iteration and exit the loop when a duplicate name is found.
b. If the condition is False, add the name to the DuplicateList variable to keep track of unique names.
Initialize and declare the DuplicateList variable as a new list of strings before the ForEach activity starts.

10. Use the Assign activity: DuplicateList = New List(Of String)
a. After the loop execution is complete, you can add a WriteLine activity or Log Message to display the result of the operation. For instance: Message: “Duplicate Found: ” + CurrentRow(“EmployeeName”).ToString.Trim
11. Finally, run the bot to test the workflow.

Share this Doc

Break

Or copy link

CONTENTS