Get record id after creation

Context

I’ve made an Airtable script to get some info automatically calling an API after populating a single field. Everything is cool besides the fact that one of the fields it’s a linked field to another table.

In this case, I would first have to create a new record in the other table and then link it (via the record id) to the table in the first “main” table.

Problem

I’d like to understand if there’s a way to get back the ID of a newly created record to link the record in the main one. I could read the values in the whole table after creation, filter them and get the ID of the created field. Tho it seems very inefficient since I’d have to read the whole thing just for a single value.

I’ve read through the docs but I couldn’t find anything about this use case. Is there a more elegant way that I’m missing?

Thanks

Welcome to the community, @Giacomo_Melzi! :smiley: If you’re using your script to create a new Airtable record, you’ll have the ID automatically. When using the createRecordAsync() table method, what’s returned is the ID of the created record.

2 Likes

Thanks @Justin_Barrett! I feel a little dumb since it was actually in the name of the variable in the docs. I was looking somewhere else :sweat_smile:

let recordId = await table.createRecordAsync

Thanks!

2 Likes

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