How can I automatically generate a new record ID in Airtable that continues sequentially from the last number in the existing data?
Solved
Auto generate a new record ID
Best answer by Saravanan_009
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.
Login to the community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
