Automating Tasks with Scripts
Airtable scripting allows you to automate tasks and extend the functionality of your bases using JavaScript. Whether you need to perform complex calculations, integrate with external services, or create custom workflows, scripts can help you achieve these goals.
[Content will go here]
[Content will go here]
let total = 0;
let tables = base.tables;
for (let table of tables) {
let query = await table.selectRecordsAsync();
total += query.records.length;
output.text(`${table.name}: ${query.records.length} records`);
}
output.text(`\nTotal records across all tables: ${total}`);
// === CONFIG ===
let estimatedDailyGrowth = 50; // ๐ Change this to your average daily new rows
let maxRowsAllowed = 50000; // ๐ Change based on your Airtable plan
// === COUNT RECORDS ===
let total = 0;
let tables = base.tables;
output.markdown("### ๐ Rows by Table");
for (let table of tables) {
let query = await table.selectRecordsAsync();
output.text(`${table.name}: ${query.records.length} records`);
total += query.records.length;
}
output.markdown(`\n**๐งฎ Total rows:** ${total} / ${maxRowsAllowed}`);
let remaining = maxRowsAllowed - total;
let daysLeft = estimatedDailyGrowth > 0 ? Math.floor(remaining / estimatedDailyGrowth) : 'โ';
output.markdown(`**๐ Est. daily growth:** ${estimatedDailyGrowth} rows/day`);
output.markdown(`**๐ Days until limit:** ${daysLeft} days`);
let tables = base.tables;
let markdownOutput = '## Airtable Schema Overview\n\n';
for (let table of tables) {
markdownOutput += `### ๐ Table: ${table.name}\n\n`;
markdownOutput += '| Field Name | Type | Description | Default Value | Options |\n';
markdownOutput += '|------------|------|-------------|---------------|---------|\n';
for (let field of table.fields) {
let options = '';
if (field.type === "singleSelect" || field.type === "multipleSelects") {
options = field.options?.choices ? field.options.choices.map(opt => opt.name).join(", ") : '';
}
let description = field.description ? field.description : 'N/A';
let defaultValue = field.defaultValue ? field.defaultValue : 'N/A';
markdownOutput += `| ${field.name} | ${field.type} | ${description} | ${defaultValue} | ${options} |\n`;
}
markdownOutput += '\n---\n';
}
// Output the result
output.text(markdownOutput);
[Content will go here]