Loop Over

Updated 1 month ago by Karan

What is Loop Over

In Byteline you can easily perform a task multiple times with a configuration of a single field called loopOver. Loop over allows the users to run the same task for each element of a loop.

You will see the below checkbox on most of the Byteline tasks for specifying a loop over array. When checked, it lets you specify the JSON path of an array to loop over. More about it soon.

JSON Introduction

JSON stands for JavaScript Object Notation. Byteline uses JSON format for the flow data. It is easy to read, write, and understand for humans as well as machines.

Two JSON constructs are important to understand data in a Byteline flow. JSON Arrays and objects.

JSON Object

The JSON object is enclosed in curly braces { } and written in key-value pair. It can have nested data when necessary. For example, a person can be represented as below JSON object

{
"name": "Jack Smith",
"email": "jack@example.com",
"address": {
"city": "Philadelphia",
"state": "PA"
}
}

JSON Array

A JSON array is a sequence of values, which can be JSON objects. The values are separated with commas and are wrapped in square [ ] brackets. You can access array values by index. For example, multiple persons can be represented as below JSON array;

[
{
"name": "Jack Smith",
"email": "jack@example.com",
"address": {
"city": "Philadelphia",
"state": "PA"
}
},
{
"name": "Susan Jones",
"email": "susan@example.com",
"address": {
"city": "Fremont",
"state": "CA"
}
}
]

For more details on JSON, check out this w3school article.

Specifying Data in Looped Array

While configuring a task node of a flow, you will get an option to run the task for each element of a JSON array.

Follow the below-mentioned steps to specify data in a looped array:

Step 1: Create a flow with required task nodes. Here is how you can create your first flow.

For this documentation, we are assuming a flow with Airtable Trigger and Webflow nodes.

The flow will sync airtable with Webflow. To put it in simple terms, the data retrieved from the airtable node shall be sent to Webflow CMS. 

Airtable Trigger 

Airtable Trigger node triggers a flow based on Airtable data changes. Once configured, this node will automatically trigger the flow for the records created and updated in the Airtable data updates. 

Follow the steps given below to configure the Airtable Trigger. 

Step 1: Click on the edit button to configure the Airtable Trigger node. 

Step 2: Enter the following:

  1. Airtable base ID
  2. Name of table 
  3. Airtable view name 
  4. Poll period   
  5. Trigger type 

Step 3: Click on the Save button. 

Airtable node will be configured successfully.

Webflow - Update Items 

Webflow CMS node allows users to manage the collections easily. With this node, users can create, update, and delete items from the CMS collection without coding.  

In the Webflow node, loop over is used in updating the Webflow CMS with the modified records from the Airtable trigger node. For example, if you have changed five records in Airtable and want to update those changes in Webflow, you will need to use the loop over feature because you are dealing with multiple records.   

Follow the steps mentioned below for the loop over configuration of the Webflow node. 

Step 1: Click on the edit button to configure the Webflow node. 

Step 2: Select the name of the site. 

Step 3: Specify the Webflow collection from the drop-down menu. 

Step 4: Select the Loop over checkbox

Step 5: Select a node from the drop-down for which you want to perform a loop over. In this case, we have just one node, i.e., Airtable Trigger. 

Step 6: Now, you need to configure the mappings. For instance, the field ‘Slug’ will map to ‘name.’ For this, you need to click on the ‘Selector’ button. 

Step 7: As ‘slug’ will map to name, select the ‘Name’ from the array.  

Note: The notations starting with @ mean that we are using a looped over data. 

Note: You can also configure the loop-over expression manually by using the @. format. 

Hence, you have successfully configured the loop over in Airtable Trigger and Webflow - Update Items nodes.


How did we do?