Using the Each Item loop

The each item loop is used to iterate through each key-value pair in an array or object. It traverses the array, processing each element in turn. This action accepts arrays or objects as input, typically received from previous actions.

About this task

Unlike the times loop, you do not need to specify the number of iterations. This loop runs multiple times, each time taking one item or an object of the array, as specified in the Array or Object field.

To use this loop, select Each Item in the Select Loop Type field and the array or object you want to iterate through, in the Number of Times field.

For example, if you want to retrieve the titles of all cards from a Trello list and email them, the Each Item loop can achieve this efficiently.

Procedure

  1. Add the Trello connector and the Loop action to the canvas and connect them.
  2. Double-click the Trello icon, select the Get All List Cards action from the Select action list, and select the Trello account that you want to use to run the action. Click Next.
    In the configuration form that opens, enter the required details to complete the action setup.
  3. Click Next.
    You are redirected to the Test Action window. Test the action to check whether you have configured it properly and return to the canvas.
  4. Hover over the Loop action icon, click the Settings icon, and configure the Loop action.

    Select the Loop type as Each Item to process all items in the list. For Source Array or Object, add the Cards array from the Trello - Get All List Cards action on the left side of the configuration window.

  5. Click Next, optionally test the Loop action, then return to the loop canvas. Finally, double-click the Loop icon to open the loop canvas.
  6. Add the Send an email action between the loop start and loop stop icons.
    This takes you back to the workflow canvas.
  7. Configure the Send an email action.
    • To - Enter the email ID of the person to whom you want to send the list of cards.
    • Subject - Provide an appropriate subject for the email. As the loop action iterates through all elements of the array, the output keys from the loop action are used in the Body.
    • Body - Locate the currentItem key under the loop output on the left side of the screen. This key contains the details of the element being processed. To fetch only the card name, click the drop-down icon, find the name key, and add it to the Body field. This extracts and includes the name of the card currently being processed.
  8. Click Next, test the loop action, and return to the loop canvas.
  9. Click the Close Loop Canvas icon.
    This action takes you back to the workflow canvas.
  10. Save the workflow and click Test to start the workflow run.
    This fetches all card details from the specified Trello list, extracts the name of each card by using the loop, and sends it to the specified recipient through email.