Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

How to Delete a Row from an Interface Table via a Script Button

118 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Lizbeth_Pena_Fl
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi all, 

I am trying to allow a user to click a button on a row within an interface to quickly delete that record. I have successfully created a script using online help to delete a row from the base view. 

 
let tableId = cursor.activeTableId;
let table = base.getTable(tableId);
let record = await input.recordAsync('Select a record to use', table);
if (record) {
   await table.deleteRecordAsync(record);
} else {
    console.log('No record was selected');
}
 
This has worked perfectly in the base view, I tested it and the buttons show active. 
Lizbeth_Pena_Fl_0-1673464914188.png

 

However, I cannot get it to work in the interface view (buttons show grayed out).

Lizbeth_Pena_Fl_1-1673464958289.png

 

Does anyone know how I can get it to work on the interface view? 
2 Replies 2

Button fields that run scripts do not work in interfaces. You need to rework the script so that it can run as an automation. Then you can use a button element in the interface to trigger the automation. Note that it will take slightly longer for the automation to delete the record versus the button field.

There will have to be several changes to the script to make it run as an automation. For example, you will not be able to use cursor.activeTableId or input.recordAsync

If you don't want to figure out the automation script yourself, my Automation Helper Scripts on my Gumroad store includes an automation script for deleting a triggering record.

So are there equivalents to  cursor.activeTableId or input.recordAsync to run a script through a button in a cell in an interface?