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.
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.
Join 13k+ entrepreneurs and receive tutorials, tips, and strategies for building smarter digital products using no-code, AI, and automation.
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:
Let’s transform how you manage Airtable today!
Imagine you need to update the status of all your records or adjust a field value for a large dataset. Doing this manually:
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.
Before we write and run the script, you’ll need to set up the Airtable Scripting app. Here’s how:
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!");
‍
Let’s understand how this script works step by step.
YourTableName
with the name of your table.YourFieldName
with the name of the field you want to update.New Value
with the value you want to apply to all records in that field.newValue
should be "Complete."let table = base.getTable(tableName);
retrieves your specified table in the base.await table.selectRecordsAsync();
gets all the records in the table so we can process them.updates
is an array where each entry specifies the record ID and the field value to update.while
loop to ensure this limit isn’t exceeded.updateRecordsAsync
function updates each batch of records until all records are processed.YourTableName
, YourFieldName
, and New Value
) with your actual table and field details.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!");
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!
Learn how to create Stripe Payments directly in Airtable