How to get an active base and view in Airtable

Sometimes you might want to update data based on the currently active table or active view. In this lesson, I will go through How to get an active base and view in Airtable. Here we will see the cursor concept of airtable. First, Install the scripting app in your base. Then Copy and paste the below code into your app.

: Code :


let tableId = cursor.activeTableId;
let table = base.getTable(tableId);
console.log(`Active Base is ${table.name}.`);

The above code will print the currently active base in the output. In this code, we are using a cursor keyword, which contains information about the user's interactions with airtable. Now, Let's add some more code and get the currently active view.


let table = base.getTable(cursor.activeTableId);
let viewId = cursor.activeViewId;
let view = table.getView(viewId);
console.log(`Active View is ${view.name}.`);

Now our new code will print an active view. You can switch between tables and views and test the code. You can use this concept in various situations like updating only the currently active table. That's all for this lesson. Will see you in the next lesson. Stay connected for more learning lessons. Feel free to contact me for Airtable consulting services by CLICKING HERE.

COPYRIGHT © 2022 · Monino Solutions ·