Help

Getting a button label in script

Topic Labels: Automations Extensions
Solved
Jump to Solution
1927 2
cancel
Showing results for 
Search instead for 
Did you mean: 
jdavis
6 - Interface Innovator
6 - Interface Innovator

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.  

jdavis_0-1675386994283.png

 

 

 

 

// 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);

 

 

 

 

 

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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.

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

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.

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.