Working with lists / arrays

Standard approaches to working with lists / arrays
Copy

Accessing data in arrays
Copy

As described in Mapping data between steps you can directly access list data returned by workflow steps by using jsonpaths such as $.steps.hubspot-1.results[0].properties.email

The [0] being used here tells us that we are digging into the first object in the 'results' array.

This is the standard method of directly sending data from one system to another, if no transformation. filtering etc. is required

Looping through arrays
Copy

Probably the most common action taken with lists is to use the loop connector to loop through the entire array and take an action on each item:

For each item in the array you can carry out any operation you need using core / helpers connectors

A common things to do here is to use the Data storage 'append to list' operation to build a new modified list, before using data storage 'get value' outside the loop, in order to retrieve the final modified array and send it on to another service.

Manipulating arrays (filtering, concatenating, extracting items etc.)
Copy

Our List Helpers connector can be used for multiple list manipulation tasks including:

  • Adding items

  • Filtering to include / exclude items

  • Sorting

  • Plucking properties e.g. email addresses from each object

  • Remove duplicates

  • Count items

Please see our Academy List Helpers course for an interactive lab which can help you get started on working with our list helpers.

Building lists
Copy

When building lists, List Helpers operations such as 'add item to list' and 'add multiple items to list' may meet your requirements.

However, it will sometimes be appropriate to make use of the Data Storage 'Append to list' operation.

This is because the List Helpers operations do not have data storage capacity.

The following example shows looping through an array of contacts in order to perform a minor transformation, create a new contact object and add it to a list that can be retrieved once complete: