← 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.
Setting Up Client Portals in Glide for Your Two-Sided Marketplace | Course Preview

Setting Up Client Portals in Glide for Your Two-Sided Marketplace | Course Preview

Welcome to my brand new course on how to build customer portals for two-sided marketplaces in Glide! Glide is an incredible tool that can revolutionize your business, as I've experienced firsthand while working on the Unicorn Factory.

Supercharge Your Webflow Landing Pages: Creating Custom Open Graph Images with Placid (Part 3)

Supercharge Your Webflow Landing Pages: Creating Custom Open Graph Images with Placid (Part 3)

Join us for the final installment of our series as we explore the creation of custom open graph images for each landing page. In Part 3, we'll use Placid to automatically generate visually appealing open graph images with custom screenshots and text. Enhance your website's social media presence and elevate your landing pages with these custom images. Complete your automation journey and unlock your website's full potential with this innovative workflow.

Supercharge Your Webflow Landing Pages: Automatically Updating Webflow CMS Items (Part 2)

Supercharge Your Webflow Landing Pages: Automatically Updating Webflow CMS Items (Part 2)

Continue your automation journey with Part 2 of our series! In this video, we'll guide you through setting up a workflow that automatically updates Webflow CMS items whenever any of your titles have been created or updated. We'll use Airtable Automations to trigger a make.com workflow that seamlessly updates your Webflow items. Streamline your website-building process and keep your landing pages up-to-date with this powerful workflow.

Supercharge Your Webflow Landing Pages: Automated Title Tags, Meta Descriptions, and More (Part 1)

Supercharge Your Webflow Landing Pages: Automated Title Tags, Meta Descriptions, and More (Part 1)

Discover how to optimize your landing pages with automated workflows! In Part 1, we'll explore how to use OpenAI's GPT-4 language model to automatically generate SEO-optimized Title Tags, Meta Descriptions, H1 and H2 headings for your landing pages. Enhance your website's search engine visibility and boost your SEO efforts with these powerful techniques.

ChatGPT 🀝 No-Code - How to create and schedule social posts with AI

ChatGPT 🀝 No-Code - How to create and schedule social posts with AI

As part of the booknotes.ai series, I will show you how to build a workflow for creating and scheduling social media marketing posts. For this example, I will be using Instagram, but you can set up this workflow for whatever other social media platform you want to use, like Twitter, LinkedIn, etc. In the first part of this series, I showed you how I created booknotes.ai, a book recommendation service created with AI.

How to build a book recommendation site with AI

How to build a book recommendation site with AI

I will show you how I used ChatGPT by OpenAI to create a book recommendation site in Webflow. I will take you behind the scenes and show you what tools I used, what processes I followed and what my thoughts are on using AI to generate these types of sites.