Scripting: Obtain Row ID of new data from createRecordAsync

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!

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:

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):

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:

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:

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.

2 Likes

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.

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.