Simple loop actions

Completed

The Loop action is used primarily when a predetermined number of repetitions is required. Another common use of simple loops is tasks where the loop index is important to the task itself. Let’s examine both cases with an example.

Consider the following flow: an Excel file contains employees’ names and email addresses. From those email addresses, employees send their business expenses - these email messages will be retrieved, and each employee’s expenses are added to their respective row in the Excel file.

First, we open the Excel report and determine the range of the data:

Screenshot of the workspace example..

When you select Excel, you need to specify the file or select a blank file as shown below.

Screenshot of the excel loop..

You need to select the Action under Excel call Get first free column/row from Excel workbook. This produces variables that can be used in the Loop.

Screenshot of the Actions table with Get first free column highlighted..

Each of the rows, from 2 until the last populated row, contains the information of an employee (row 1 isn't included, because it contains headers). We have to both read and write to these rows, so an index variable has to be used. Therefore, we choose to use a loop action:

Screenshot of the Loop action properties.

Within the loop, we set the sum of expenses to 0, read the employee’s email address, and retrieve the emails sent from their account to the designated one, with the subject line Company Expense:

Screenshot of the workspace loop parameters.

In this case inside the Loop, we use the Read from Excel worksheet

From here we use the Retrieve the Values of named cells and use the cell Name in the Name field.

Screenshot of Read Excel worksheet..

The next action we add will be the Retrieve emails action as shown below. Note that you need to find your email IMAP information from your IT Department.

Screenshot of the Retrieve emails action properties dialog.

Finally, the email’s body, containing the expense amount, will be written into the respective cell. Since only one email message is expected, we use the body of the first (and only) email in the list of retrieved emails:

Screenshot of the completed workspace loop example.

Both reading the email address, and writing the expense amount (actions 5 and 7) require the use of the loop index variable. This ensures that each repetition of the loop accesses a different row in the Excel file.