Ask AI
Skip to main content

For

Function: For

The "For" function allows you to repeat a specific action multiple times, iterating through a sequence of numbers. You define a starting number, an ending number, and how much to increase the number by each time. For every step within this numerical range, the chosen action will be performed. During each repetition, the current number in the sequence is available as a special variable called INDEX, which you can use within the parameters of the action being repeated. This is incredibly useful for automating tasks that need to be done repeatedly, such as processing a list of items, generating sequential data, or performing an operation a set number of times.

Input,

  • Start (Number, Required): The initial value of the counter when the loop begins.
  • End (Number, Required): The value at which the loop will stop. The action will be executed for all numbers up to, but not including, this End value.
  • Increment (Number, Required): The amount by which the counter increases after each repetition of the action.
  • Action (Action, Required): The specific action you want to execute repeatedly. This could be any other action available in your platform.
  • Action parameters (Action Parameters, Optional): Any specific inputs required by the Action you selected. You can use the special \{INDEX\} variable within these parameters to refer to the current number in the loop.

Output,

  • Action outputs (Action Outputs): Any results or data generated by the Action that was executed repeatedly. If the repeated action produces an output, this will collect all outputs from each iteration.

Execution Flow,

Real-Life Examples,

Example 1: Create Multiple Tasks with Sequential Naming

Imagine you need to create a series of tasks for a project, each named sequentially.

  • Inputs:
    • Start: 1
    • End: 4
    • Increment: 1
    • Action: Create Task (Assume this is an existing action in the platform)
    • Action parameters:
      • Task Name: Project Alpha - Task \{INDEX\}
      • Due Date: 2024-12-31
  • Result: Three new tasks are created: "Project Alpha - Task 1", "Project Alpha - Task 2", and "Project Alpha - Task 3", all due on December 31, 2024.

Example 2: Update Inventory Levels for a Range of Product IDs

You have a range of product IDs (e.g., 100 to 102) for which you need to decrease the inventory by a fixed amount.

  • Inputs:
    • Start: 100
    • End: 103
    • Increment: 1
    • Action: Update Product Inventory (Assume this action exists)
    • Action parameters:
      • Product ID: \{INDEX\}
      • Quantity Change: -5
  • Result: The inventory level for product IDs 100, 101, and 102 is decreased by 5 units each.

Example 3: Send Weekly Reminders Every Other Week

You want to send a series of reminder emails to a user every other week for a period of 6 weeks.

  • Inputs:
    • Start: 0
    • End: 7
    • Increment: 2
    • Action: Send Notification (Assume this action exists)
    • Action parameters:
      • Recipient Email: [email protected]
      • Subject: Weekly Report Reminder - Week \{INDEX\}
      • Message Body: Please submit your report for week \{INDEX\}.
  • Result: Four notification emails are sent to [email protected] with subjects "Weekly Report Reminder - Week 0", "Weekly Report Reminder - Week 2", "Weekly Report Reminder - Week 4", and "Weekly Report Reminder - Week 6", each containing the corresponding week number in the message body.