HELP
 / 
Workflows
 / 
Workflows: Repeat node

Workflows: Repeat node

This article explains the functioning of Repeat nodes that can be configured as a part of workflows. The function of a 'Repeat Node' is also referred to as a 'loop'.

Working

Automating repetitive actions until the break condition is true, as per the use case.

Use Cases:

  • Reminder notifications for:

           → Push notification for customers on payment dues.

            → SMS notification for customers to remind about expiration date of service

            → Email Notification for vendors about renewals, contracts or approvals.

            → Slack Notification for employees reminding about pending tasks.

  • Creating or editing multiple submissions using repeat.
  • Fetching or delivering data from the REST API on a timely manner.

Editing the block

Click on the repeat block and start editing on the right panel.

Step Name

This is the name of the workflow that appears on the left side.

Number of times

Number of times is the count of executions for the repeat function to run. It can also be explained as the number of loops that should run.

The number of times can also be determined using a formula.

Break Condition

Break condition is to stop the repeat function prematurely by evaluating a formula. This means that the loop will stop if the given condition is true, even if the total count of 'number of times' has not completed.

Setting the break condition to ‘false’ will allow the loop function of the repeat node to execute completely.

Parent Step

Parent step refers to the function which is just above the repeat node. Here, it is the Start function.

Prominent examples of repeat node use cases

1.   How to use Repeat nodes to iterate on data from Copyable Sections?

Use Case: Customer orders a list of items and their respective quantities. Shop owner has to receive that order as separate items. This helps the shop owners to more easily determine and track their stock.

For example:

Customer orders: A-2 kg, B-3 kg, C-4 kg. This is one submission. 

The shop owner has to receive it in the form of: A-2kg. B-3kg. C-4 kg. These are 3 different submissions.

There are two apps:
Customer Order App - for customers.

Shop Owner Order - for business owners.

Both the apps are the same and contain the same fields: Item and Quantity. The list of items in both the apps is also one and the same.

List of items: item 1, item 2, item 3, item 4, item5.

Customer orders: item 1-4kg, item 2-3kg, item 5-2kg. This is a single submission.

Shop owner receives: Three separate submissions.

item 1-4kg - 1st submission

item 2-3kg - 2nd submission

item 5-2kg - 3rd submission

Repeat node setup in Customer Order App for customer

Repeat:

Number of times - COUNT (@item)

The number of times this process should run is the number of items the customer orders.

Break Condition - false

When the number of items counted by the repeat node is over, the repeat function will stop.

Create submission:

Select App - Shop Owner Order(Shop owners app)

Submissions will be created in the Shop Owner Order app.

Field Values:

Item - INDEX(@item,@index)

Quantity - INDEX(@quantity,@index)

The above functions imply that the 1st item is assigned the 1st index (serial number) and correspondingly the 1st quantity is assigned the 1st index (serial number.) Similar logic applies to further items too.

The logic of this repeat function:

Step 1: The repeat node will assign item 1 as index 1 and corresponding quantity index 1. The first submission is created.

Step 2: Repeat node goes back and assigns item 2 as index 2 and corresponding quantity index 2. The second submission is created.

Step 3: Repeat node goes back and assigns item 3 as index 3 and corresponding quantity index 3. The third submission is created.

Step 4: Repeat node stops as the items are over.

2.   How to use Repeat nodes to check for status updates at regular intervals?

Use Case: Send email notifications to employees for any pending work.

The repeat node runs in regular intervals of the specified time and checks for the status of the work. If the status reads 'work in progress' then it sends a reminder email to the employee, stops for the specified time, checks again and if the work is still not completed, it again sends an email reminder. This goes on for a maximum of 30 times. The repeat node will stop anywhere in the middle of 30 times if the status of the work is completed.

Repeat node setup

Repeat node :

Number of times - 30 (max)

The number of times this loop should run, which means the number of times an email is sent to the employee until the status of the work is ‘Work in progress’. 

Break Condition - @status=”Completed”

Stop the repeat node if the employee finishes the pending work and the status of the work is changed to ‘completed’.