Ask AI
Skip to main content

For each

Function: For each

This function allows you to perform a specific action repeatedly for every item within a list, a collection of data, or a set of records. It's like telling the platform, "For every single item in this group, do X." This is incredibly useful for automating tasks that need to be applied to multiple pieces of data, ensuring consistency and efficiency.

Input

  • List: The collection of items (like a list of customers, products, or tasks) that you want to process one by one. This can be a simple list, a page of data from your database, or a map of key-value pairs. (Required)
  • Limit: An optional number that specifies how many items from the beginning of your list you want to process. If you have a list of 100 items but only want to process the first 10, you would set the limit to 10. If left empty, all items will be processed. (Optional)
  • Item Name: A temporary name you give to each individual item as the action processes it. This name acts as a placeholder for the current item being worked on within the repeated action. For example, if you're looping through a list of "Customers," you might name each item "CurrentCustomer." (Required)
  • Action: The specific task or set of steps you want the platform to perform for each item in your list. This could be another function, a custom workflow, or any other action available in your platform. (Required)
  • Action Parameters: If the action you've chosen requires additional information to run, you can provide those details here. These parameters will be passed to the action for each item it processes. (Optional)

Output

  • Action Outputs: This provides access to any results or data generated by the action that was executed for each item in the list. You can then use these outputs in subsequent steps of your workflow. (Optional)

Execution Flow

Real-Life Examples

  1. Sending Welcome Emails to New Users:

    • Scenario: You have a list of new users who signed up today, and you want to send each of them a personalized welcome email.
    • Inputs:
      • List: List of New Users (e.g., retrieved from a database query)
      • Limit: (Empty, process all new users)
      • Item Name: CurrentUser
      • Action: Send Email (a pre-defined action in your platform)
      • Action Parameters:
        • Recipient Email: CurrentUser.EmailAddress
        • Subject: "Welcome to our platform, CurrentUser.FirstName!"
        • Body: "Dear CurrentUser.FirstName, welcome aboard..."
    • Result: A personalized welcome email is sent to every new user in the list.
  2. Updating Inventory Levels After Sales:

    • Scenario: After a batch of online orders is processed, you have a list of products that were sold, and you need to reduce their stock levels in your inventory system.
    • Inputs:
      • List: List of Sold Products (e.g., from today's orders)
      • Limit: (Empty, update all sold products)
      • Item Name: SoldProduct
      • Action: Update Product Stock (an action that modifies inventory)
      • Action Parameters:
        • Product ID: SoldProduct.ProductID
        • Quantity Change: -SoldProduct.QuantitySold (negative to reduce stock)
    • Result: The stock level for each product in the List of Sold Products is updated in the inventory system.
  3. Generating Monthly Reports for Specific Departments:

    • Scenario: You need to generate a monthly performance report for the top 5 departments based on sales figures.
    • Inputs:
      • List: Top 5 Departments (e.g., a filtered list from a "Departments" data collection)
      • Limit: 5
      • Item Name: Department
      • Action: Generate Department Report (an action that creates a PDF report)
      • Action Parameters:
        • Department Name: Department.Name
        • Reporting Period: Current Month
    • Result: Five separate monthly performance reports are generated, one for each of the top 5 departments.