Help

Re: Auto generate a new record ID

Solved
Jump to Solution
473 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Thomas039
4 - Data Explorer
4 - Data Explorer

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

1 Solution

Accepted Solutions
Saravanan_009
8 - Airtable Astronomer
8 - Airtable Astronomer

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.

See Solution in Thread

2 Replies 2

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)




Saravanan_009
8 - Airtable Astronomer
8 - Airtable Astronomer

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.