Launched: get the active table/view in the scripting block!

Hi y’all!

The Cursor API is now accessible within the scripting block. You can use it to access the currently active table ID and view ID. This is particularly useful for removing the need for your users to manually select tables and views while running a script.

Learn more about how to use it in our scripting block API documentation.

Hope you all enjoy the new feature; happy scripting!


I can’t seem to get cursor. activeTableId to work while scripting in an automation. Has this been applied there yet?

Would like to pull the name of the table from a record when an automation is triggered on that record. Not sure if active table is even the answer for that but it’s my best bet so far.


There is no active table in an automation script. The concept only applies in the case when a user is looking at the user interface.

You can the the table ID for the triggering record from the record url. You can get the record url as an input variable. From that, you can get the table object, which will give you the table name. Of course, once you have the table object, you probably don’t need the table name.

Hey, this is neat! Thanks for sharing @Tim_Deng, it works well. You now have me thinking of all the ways that I need to start using this. :smiley:


I think, that example should be here.
script to order lookup values in cell according to their some ‘rating’ in other table, when you know just lookup and rating field names. designed to run from button. indeed, that means - to order links in link field, as lookup values follow their order.
also, @Sefik_Serengil may find something useful for his post

if (cursor.activeTableId){
const table=base.getTable(cursor.activeTableId)
const record = await input.recordAsync('', table);
const lookup=table.getField('Lookup_field_to_order')
const target=table.getField(lookup.options?.recordLinkFieldId)
const linkTOids=record?.getCellValue(target).map(lnk=>
const table2=base.getTable(target.options?.linkedTableId)
const query=await table2.selectRecordsAsync({fields:[],
if (record) await table.updateRecordAsync(,{[]:idsTOlink})}

Can you specify on what that line of code will look like? I’m having a hard time pulling anything other than the URL.

You need to parse the table ID from the url. The base ID is the part between the slashes that starts with app and is followed by 14 alphanumeric characters.

Oh ok, so I did this once here… I was just thinking maybe there was an easier way. Maybe my method is sloppy?

let inputConfig =input.config();


// Pull Table Id from URL
let globalRecordUrl = inputConfig.globalRecordUrl

//Find the ID in the Url by searching /tb
let tableIdlink ="/tb");

//Find the end of the ID by adding 18
let linkEnd = tableIdlink + 18

//Pull out the ID by defining start and end point to trim URL string
let sourceTableId = globalRecordUrl.substring(tableIdlink +1, linkEnd);

// Defining Table by inserting found ID
let sourceTable = base.getTable(sourceTableId)
let sourceTableName =

output.set ('Source Table Name', sourceTableName)

There are many ways to do things in code. I’ve experimenting with getting the table id using regular expressions, and with using split. Currently my favorite method is regular expressions, but some people are not comfortable with regular expressions.

Ultimately you should use a method that you understand and that makes sense to you. And do not be afraid to refactor you code when you feel a different method makes more sense.

1 Like