Help

Re: Automation script, get table for created/updated record

Solved
Jump to Solution
1838 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Yoway_Buorn
5 - Automation Enthusiast
5 - Automation Enthusiast

I want to hit an API much like the currency conversion example. However, the example updates all the records in one go. Instead, I would like to fetch the API result for just the one record that was either created or updated.

The record ID is available in the input, so that should work fine. But what about the table name? I happen to be partitioning this data into multiple tables (each with the exact same schema). The table ID or name doesn’t appear to be available from the trigger/input. And every example I’ve seen hard-codes the table name in the script. Since the automation is triggered on a record which exists within a table, I believe a reference to the table should be available, but I can’t seem to find it.

Is there any way to get the name or ID of the table within which the record was created or updated?

1 Solution

Accepted Solutions
Kamille_Parks
16 - Uranus
16 - Uranus

~ insert obligatory “Why not just use one table” warning here~

It does actually its just hidden inside the record url variable. Record URLs follow the format

https://airtable.com/tableId/viewID(optional)/recordId

In your script you could extract the table ID from the record UL by doing:

let {recordURL} = input.config()
let tableId = recordURL.split("/")[3]

See Solution in Thread

3 Replies 3
Kamille_Parks
16 - Uranus
16 - Uranus

~ insert obligatory “Why not just use one table” warning here~

It does actually its just hidden inside the record url variable. Record URLs follow the format

https://airtable.com/tableId/viewID(optional)/recordId

In your script you could extract the table ID from the record UL by doing:

let {recordURL} = input.config()
let tableId = recordURL.split("/")[3]

Thank you Kamille! I literally just noticed the tableId in the URL as you were typing this :slightly_smiling_face: And yes…you are right about the one table warning. I’ll see if I can move it all into one table first. Thank you much.

Yoway_Buorn
5 - Automation Enthusiast
5 - Automation Enthusiast

Oh BTW the reason for multiple tables (with the same schema): the schema(s) were created by a non-technical person who thought of tables as spreadsheets. I now see that we’ve also got individual bases for each client. I’m going to have to refactor the schema since Airtable seems to actually be a database with a spreadsheet-like UI (+ other views).