Example: Using the ‘Times’ Loop
Suppose, you want create 3 folders in your OneDrive account. Instead of creating separate workflows to create a single folder, use the Times loop.
For this example, you need to perform the following steps:
The workflow is as shown in the following figure:
Step 1: Add actions to the canvas and create the workflow
1. Drag the Loop action to the canvas.
2. Drag the
Make Folder action under
OneDrive onto the
Loop block. This action is automatically connected to
.
3. Connect the
Make Folder action to
.
Step 2: Configure the Make Folder action
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see
Make Folder.
1. In the Folder Name field, map the value of currentIndex of the Loop action.
For each execution of the loop, the value of currentIndex is the index of the current iteration.
2. Append Folder- to the mapped value in the Folder Name field.
If the mapped value is {{$a0.currentIndex}}, then the updated value of the Folder Name field is Folder-{{$a0.currentIndex}}, where a0 is the action ID of the Loop action.
Step 3: Configure the Loop action
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see
Loop.
1. In the Select Loop Type list, select Times.
2. In the Number of Times field, enter 3.
Step 4: Execute the workflow
Click Save to save the workflow, and then click Execute to run the workflow.
When the workflow is being executed, the current iteration number and the total number of iterations is displayed above the Loop block, as shown in the following figure:
The output in the Debug Panel provides the following details of the Loop execution:
When iteration 1 of the Make Folder action executes, Folder-1 is created, in iteration 2, Folder-2 is created, and in iteration 3, Folder-3 is created.