← All blog posts

How to run a script for an array of records in Airtable Scripts

Learn how to run a script for an array of records in Airtable records. This method can be used to bulk update records.

October 13, 2022

A very common automation use case that needs to be solved for is running workflows for many records rather than just one. Tools like Nobull from Finsweet, Parabola or Make.com are very good at allowing to do this, but did you know with only a few lines of codes you will be able to do the same in Airtable Scripts.

Importing your table

The first thing we want to do writing our script is to make sure we are importing an array of records rather than just importing a single record. We can do this using the "query.records" function after we define our base and table.

Running a script for every record in our array

Once we have successfully queried our set of records in our table or view, we will now be able to use the for function to run a script or function for each record within our array. Once we have added our script within the for function, Airtable scripts will run for through each and run the script that we specified.

After your run your script, you should see a list of properties returned

How to use the "for" function

The "for" function can be used for a lot of different things, but properly the most common use case is to bulk create or bulk update records. If for example, you have added a new fields to your Webflow CMS and you want to update all of your records with a value that sits inside of Airtable, then you will be able to do just that with the for function.

Use the code


//import the table
let table = base.getTable("Properties");
let query = await table.selectRecordsAsync();
let records = query.records;

console.log(records);

//run a script for each record in a table
for (let record of records){
    //if trigger automation field is "approved" run the script
    if (record.getCellValue("Trigger Automation").name === "Approved" || (record.getCellValue("SQFT")>2000)){
            output.text(`${record.name} is included in our properties table`)
    }
}
Copy

Dive Deeper with the Stripe Payment Links scripting series

Learn how to use Airtable Scripts to generate Stripe Payment Links for your online store and more!

Learn more →
Subscribe to the newsletter!

Get notified when I publish my next video or blog

😘 Got it!
Oops! Something went wrong while submitting the form.
How to use Whalesync for two-way syncing between Airtable and Webflow

How to use Whalesync for two-way syncing between Airtable and Webflow

I checked out Whalesync, a tool for two-way syncing between tools like Airtable, Webflow, Bubble, Noton and more, to see how useful two-syncing is.

How to build a dynamic testimonial section with the Webflow CMS

How to build a dynamic testimonial section with the Webflow CMS

Learn how to create a dynamic section in the Webflow CMS for product reviews, testimonials, and more. Watch the step-by-step process of designing, building, and automating a brand-new section on my profile page.

How to allow clients to manage your no-code builds with Airtable Interfaces

How to allow clients to manage your no-code builds with Airtable Interfaces

I help a lot of people set up bases for their marketplaces or sometimes even for clients, and a question that keeps coming up is how can you allow your clients to safely manage their Airtable base without overwhelming them with the complex setup?

How to instantly trigger Airtable workflows in make.com using webhooks

How to instantly trigger Airtable workflows in make.com using webhooks

If you want to run a make.com workflow that triggers when something happens in Airtable, you typically have to wait for 5 - 15 minutes depending on how you set your schedule - unless you use a webhook fired from inside Airtable Automations.

How (and why) to use output.set in Airtable Automations

How (and why) to use output.set in Airtable Automations

Output.set is a must-know function for anyone setting up workflows in Airtable Automations. It allows us to reuse variables in automation steps that we get from JSON responses.

Building a customer dashboard for my marketplace with Glide

Building a customer dashboard for my marketplace with Glide

In this video, I show what I managed to build in my first week of using Glide. The goal at the start of the week was to figure out what exactly I could do with Glide. A week later, I had a fully functioning prototype for a customer dashboard for my freelancer marketplace Unicorn Factory