Skip to content

Working with Collections

It's quite common for people to deal with collections/lists as part of their processes. For example, as part of your process automation, you may need to work with a collection of files received from an email attachment, or work with a collection of rows loaded from Google Sheet. Sometimes, you want to run a logic on the collection as a whole, for example, saving all email attachments to a Google Drive folder. And sometimes, you may want to run a set of actions for each item in the collection, for example, you may want to generate and send an email using each item the the collection of rows you have loaded form a Google Sheet.

zenphi has a few actions which help you work with the collections.

The main purpose of the 'Loop Collection' connector is to loop through each result in a list so that they can be dealt with one-by-one (using the Loop List operation).

It can also be used to loop through individual fields associated with each customer/account/record etc. to make checks and perform actions on each field (using the Loop Object operation).

Foreeach Item

The Foreach Item action is used to loop through a collection of items, and execute one or more action for each item. For example, say you have a list of employees in a Google Sheet and you want to generate a personalized certificate for each employee and email it to her/him. So, first you load a list of employees from a Google Sheet Read Rows action. Read Rows return a collection of Rows (in our case each row is an employee information).

zenphi Collection Load Employees

Then, then we can configure the Foreach Item action to loop through the Rows

zenphi Collection Foreach Config

Any action within the Foreach Item boundary gets executed foreach item (Row in this case), one item at a time. In the below example, for each Row (employee) in the collection, Generate Certificate and Email Certificate actions will be executed.

zenphi Collection Foreach Item

Tip

In order to access the current item properties in the loop from the Token Picker, you need to select one or more property of the Item under the Foreach action the

zenphi Collection Foreach Item Properties

Query Collection

The Query Collection action is used to extract an item from a collection. You can extract

  • The first item
  • The last item
  • or the item at a specific location in the collection (ex. 5th item)

zenphi Query Collection

Project Collection

The Project Collection action is used to extract one of the properties of all items in a collection. For example, you can extract the email address property of all employees in the above example. The output will be a collection of email addresses which can be directly used in the To property of the Send Email action.

zenphi Query Collection