Help

Scripting: Obtain Row ID of new data from createRecordAsync

1996 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Rose_Haft1
8 - Airtable Astronomer
8 - Airtable Astronomer

Hi there - I am using createRecordAsync and am wanting to know how I can obtain the row ID or other identifying info from the new row that was created without needing to use a time stamp and then text match.

Thanks in advance!

2 Replies 2

Hi @Rose_Haft1,

There isn’t any concept of a “row” ID, in particular, in Airtable. If you re-sort your table, the row numbers on each record change to match their new positions in the table.

There are at least two other alternatives you could use here that wouldn’t require using a timestamp, although I’m not certain exactly what your goal is or what you are struggling with.

Record ID

The first is to use the recordId that is returned natively by the createRecordAsync() function on success:
CleanShot 2020-10-27 at 09.04.52

The documentation doesn’t officially call out that this will, after resolving the promise, return the recordId of the new record created, but their example hints at this fact. The recordId is unique per record. You cannot visibly see it on your records, by default, but you will see the corresponding Id in the URL bar of your browser if you expand a record (the part that starts w/ rec and is always exactly 17 alpha-numeric characters long):
CleanShot 2020-10-27 at 09.09.42

You can also create a Formula field that returns this recordId on each record, so that it is visible on the records in your base:
CleanShot 2020-10-27 at 09.12.36

Autonumber

Alternatively, but I would argue less desirably, you could use an Autonumber field, which will be a unique number for each record generated, and thus could be used as an ID:
CleanShot 2020-10-27 at 09.16.13

I say this is less desirable to use in a Scripting environment because most functions in the API that attempt to identify a record are going to natively use the recordId for that. In the Scripting environment, you are almost always going to be better off using the native recordId as opposed to using your own fabricated ID for locating records.

Hopefully that helps.

Rose_Haft1
8 - Airtable Astronomer
8 - Airtable Astronomer

Thanks. I am wanting it to be fully automated. Using the timestamp is the only way I’ve been able to get this to work at the moment.