Blog
Code For No-Coders
Airtable Scripts: How to Bulk Update Multiple Records Easily

Airtable Scripts: How to Bulk Update Multiple Records Easily

Discover how to run scripts for multiple records in Airtable and master bulk updates with ease. Learn to use the for function to automate your workflows.

connor finlayson
Connor Finlayson
October 12, 2022

I've published a newer version of this post with more up-to-date information and insights.

👉 Click here to read the latest version

Join The Founder's Inbox

Join 13k+ entrepreneurs and receive tutorials, tips, and strategies for building smarter digital products using no-code, AI, and automation.

Thank you! We will reach out when we have updates!
Oops! Something went wrong while submitting the form.

Tired of spending hours manually updating records in Airtable, one by one? Imagine turning a tedious task that takes hours into a 30-second process! Whether you’re managing projects, tracking inventory, or updating customer data, this step-by-step guide will show you how to automate bulk updates in Airtable using a simple script. By the end, you’ll not only save time but also feel empowered to tackle automation with confidence—even if you’re new to scripting.

What We’ll Cover:

  • Why bulk updating with a script is a game-changer for productivity.
  • How to set up the Airtable Scripting app in minutes.
  • A beginner-friendly explanation of how the script works.
  • A real-world example to help you get started immediately.
  • Practical tips for ensuring your script runs smoothly every time.

Let’s transform how you manage Airtable today!

Why Use a Script for Bulk Updates?

Imagine you need to update the status of all your records or adjust a field value for a large dataset. Doing this manually:

  • Takes too much time.
  • Increases the chance of errors.
  • Gets repetitive and tedious.

Using a script solves these issues by automating the updates. Airtable’s Scripting app allows you to write JavaScript code to make changes quickly and accurately.

Getting Started: Setting Up the Scripting App

Before we write and run the script, you’ll need to set up the Airtable Scripting app. Here’s how:

  1. Open your Airtable base.
  2. Click on the “Apps” button in the upper right corner.
  3. Click “Add an app.”
  4. Search for “Scripting” and add it to your base.
  5. Open the Scripting app, and you’re ready to write and run your script.

The Script: How It Works

Here is the script we’ll be using:

// Replace with your table name
const tableName = "YourTableName";

// Replace with the field name(s) you want to update
const fieldToUpdate = "YourFieldName";
const newValue = "New Value"; // Replace with the desired value

// Get the table
let table = base.getTable(tableName);

// Fetch records to update
let query = await table.selectRecordsAsync();
let records = query.records;

// Prepare an array for batch updating
let updates = records.map(record => ({
    id: record.id,
    fields: {
        [fieldToUpdate]: newValue
    }
}));

// Airtable API restricts batch size to 50
while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

output.text("Bulk update completed!");

‍

Breaking Down the Script

Let’s understand how this script works step by step.

  1. Define the Table and Field
    • Replace YourTableName with the name of your table.
    • Replace YourFieldName with the name of the field you want to update.
    • Replace New Value with the value you want to apply to all records in that field.
  2. For example, if you want to set all records’ status to “Complete,” the newValue should be "Complete."
  3. Access the Table
    • let table = base.getTable(tableName); retrieves your specified table in the base.
  4. Fetch Records
    • await table.selectRecordsAsync(); gets all the records in the table so we can process them.
  5. Prepare the Updates
    • updates is an array where each entry specifies the record ID and the field value to update.
  6. Batch Updates
    • Airtable limits bulk updates to 50 records at a time. The script processes records in batches using a while loop to ensure this limit isn’t exceeded.
  7. Run the Updates
    • The updateRecordsAsync function updates each batch of records until all records are processed.
  8. Output Confirmation
    • Once all records are updated, the script outputs “Bulk update completed!”

How to Run the Script

  1. Copy the script and paste it into the Scripting app in Airtable.
  2. Replace the placeholders (YourTableName, YourFieldName, and New Value) with your actual table and field details.
  3. Click “Run” to execute the script.
  4. Watch as your records are updated in seconds!

Example Use Case

Let’s say you have a table named “Tasks” with a field called “Status.” You want to mark all tasks as “Complete.” Here’s how the script would look:

const tableName = "Tasks";
const fieldToUpdate = "Status";
const newValue = "Complete";

let table = base.getTable(tableName);
let query = await table.selectRecordsAsync();
let records = query.records;

let updates = records.map(record => ({
    id: record.id,
    fields: {
        [fieldToUpdate]: newValue
    }
}));

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

output.text("Bulk update completed!");

Tips

  • Test with a small dataset first to ensure the script works as expected.
  • Back up your Airtable base before running the script, especially if you’re making significant changes.
  • Use clear and descriptive names for your table and fields to avoid errors.

Wrapping Up

With this script, you can save countless hours and streamline your workflows in Airtable. Whether you’re managing a project, tracking inventory, or updating customer data, scripting is a powerful tool to add to your arsenal.

If you’re ready to take your Airtable skills to the next level, try out this script and watch how it transforms your productivity. Have questions or need further help?

Happy automating!

MVMP LABS COURSE

Payment Links with Airtable Scripts

Learn how to create Stripe Payments directly in Airtable

  1. MVMP Labs: Join our online community for first-time founders building no-code marketplaces. Get access to exclusive resources, step-by-step guides, and a supportive network of peers who are on the same journey as you.
  2. Studio: Let my team handle the heavy lifting. We’ll build your automations, build entire MVPS, basically let you focus on building the business, whilst we build the systems.
  3. Learn No-Code on YouTube: Follow my free, hands-on tutorials where I teach you how to build and automate no-code marketplaces step-by-step. Subscribe here for weekly videos and start creating today.