Feb 02, 2023 05:06 PM - edited Feb 02, 2023 05:16 PM
Hi, I'm looking to just get some sort of identifier of the button pressed. I would like to have several buttons run a single script and just identify which button is pressed in the script.
I was following this code from the tutorial for getting the button working, but not sure what to access to get the label of the button pressed. Just the record.
// Change these to match your base.
let table = base.getTable('Tasks');
// When run from a button field, the script skips the prompt
// and automatically uses the button's record.
let record = await input.recordAsync('Choose a record', table);
Solved! Go to Solution.
Feb 02, 2023 05:24 PM
It is not possible for a script to know which button field called the script.
It also is not possible for the button to pass any parameters to the script.
It looks like you want to have a series of buttons that set the records status. In cases like this I often have a single script with different script settings where each script is called by a different button. For maintenance, the body of the script is the same and the script settings identify the actual desired status. I still have to copy/paste the script into multiple instances of Scripting Extension. I usually put all the scripts in the same dashboard to keep things tidy.
Not what you want to hear, but at least you can stop looking for now.
Feb 02, 2023 05:24 PM
It is not possible for a script to know which button field called the script.
It also is not possible for the button to pass any parameters to the script.
It looks like you want to have a series of buttons that set the records status. In cases like this I often have a single script with different script settings where each script is called by a different button. For maintenance, the body of the script is the same and the script settings identify the actual desired status. I still have to copy/paste the script into multiple instances of Scripting Extension. I usually put all the scripts in the same dashboard to keep things tidy.
Not what you want to hear, but at least you can stop looking for now.
Feb 02, 2023 05:37 PM
I really appreciate your prompt response, and the workflow you outlined dealing with this challenge. Not too bad in my case with only 4 options. But I wish airtable had a bit more support for their scripting foundation than they do.