Automation script, get table for created/updated record

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?

~ 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]
1 Like

Thank you Kamille! I literally just noticed the tableId in the URL as you were typing this :slight_smile: 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.

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

1 Like

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