Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: How to get Latest created record in airtable?

2455 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Rohith_S
6 - Interface Innovator
6 - Interface Innovator

Hi everyone,

I have a table with created date column and some data, as soon as new record is created I have created a automation script the extracts the newly created record by sorting this column in descending order and getting the getting the first record by using query.records[0](which is the last record created, because it is in descending order).

My question is, is there any way other than this to extract the latest record created?

I also have a column that is auto increment id, I was thinking of extracting the highest value from this column as the latest record, but could not find how to find max value of column by writing in automation script.

Thank you

4 Replies 4

Does your automation script need to find the latest record or do you need to indicate the latest record for something outside of the automation?

If your automation script wants the latest record, and your automation us running off a “record is created” trigger, that triggering record is the latest record at the moment it was created. Thus the automation script can simply use the triggering record as the latest record.

If you need to have a different way of indicating the latest record, such as a checkbox field marked for the latest record. Have an automation run whenever a new record is created that clears the checkbox from the one previous record with the checkbox, and then sets the checkbox in the new record.

Hey, thank you for replying
Yes, I am writing 2 automation scripts for both - when the record is created for one table and when checkbox is ticked for another table, my question is how do you use the triggering record in script or how do you get the id of triggering record in script?
I don’t want to sort all the records and get the latest record, I was wondering if there is any other way.

Use an input variable. Create the variable in the left pane of the script editor and set the value to the record ID.

Then in the script, use input.config to get the value of the input variable.

const inputConfig = input.config()
const recordID = inputConfig["recordId"]

Looks like this is a duplicate thread that has already been answered: