Skip to main content

How can I automatically generate a new record ID in Airtable that continues sequentially from the last number in the existing data?

Hmm, if the autonumber field doesn't work you might need to use scripting I'm afraid (https://support.airtable.com/docs/number-based-fields-in-airtable#autonumber-fields)





To automatically generate a new record ID that continues sequentially in Airtable, you can use a combination of a formula field and a script. Here’s a step-by-step guide:

Example script:

let table = base.getTable("Your Table Name");
let query = await table.selectRecordsAsync();

let maxId = 0;
for (let record of query.records) {
let id = record.getCellValue("Record ID");
if (id > maxId) {
maxId = id;
}
}

let newId = maxId + 1;
await table.createRecordAsync({
"Record ID": newId,
// Add other fields as needed
});

This script will ensure that each new record gets a unique and sequential ID based on the highest existing ID.


Reply