Sep 08, 2021 09:41 AM
Hi community!
Is it possible to trigger a built-in Airtable automation (example: Create a custom automation) when a button is clicked?
Thanks!
Solved! Go to Solution.
Sep 10, 2021 07:56 AM
You can use a button to trigger a script, as @kuovonne notes, and that script can flip a checkbox. THat change can trigger the automation (meets a condition).
Here’s a quick script I hacked toegther from various sources that does this:
let table = base.getTable("Pipeline"); //The name of the table you're in here
let record = await input.recordAsync('Pick a record', table);
if (record) {
if (record.getCellValue("flipme")===true) {
table.updateRecordAsync(record, {'flipme': false});
} else { table.updateRecordAsync(record, {'flipme': true});}
output.text('Value flipped');
}
All this does is take the given record and change the value of a checkbox field called “flipme” from checked to unchecked (or back the other way). Easy to modify to whatever specific need you have.
Create a button field that runs this script and you’re set.
Sep 08, 2021 01:01 PM
If the button launches a script that POSTs to the webhook, then yes. Otherwise no.
Just a note: No webhook can create an automation.
Sep 08, 2021 03:23 PM
Or the button could run a script that creates or updates a record such that the change triggers an existing automation.
But it still requires a script.
Sep 10, 2021 07:56 AM
You can use a button to trigger a script, as @kuovonne notes, and that script can flip a checkbox. THat change can trigger the automation (meets a condition).
Here’s a quick script I hacked toegther from various sources that does this:
let table = base.getTable("Pipeline"); //The name of the table you're in here
let record = await input.recordAsync('Pick a record', table);
if (record) {
if (record.getCellValue("flipme")===true) {
table.updateRecordAsync(record, {'flipme': false});
} else { table.updateRecordAsync(record, {'flipme': true});}
output.text('Value flipped');
}
All this does is take the given record and change the value of a checkbox field called “flipme” from checked to unchecked (or back the other way). Easy to modify to whatever specific need you have.
Create a button field that runs this script and you’re set.
Sep 22, 2021 05:00 PM
Thanks @David_Solimini and @kuovonne for the tip! Smart and easy (indirect) way to make it happen.