- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 29, 2024 03:39 PM
How can I automatically generate a new record ID in Airtable that continues sequentially from the last number in the existing data?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 30, 2024 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 29, 2024 11:55 PM
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)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 30, 2024 11:53 AM
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.
