Is it possible to pass parameters on a signed script?
I have a spreadsheet and made a couple of buttons signing functions to each.
Sample function:
function foo(){
return "bar";
}
Calling this function on a cell
=foo()
returns me bar
, signing this function to a button
foo
returns me nothing but of course it works. I mean the script cant return a string to an image (whats actually my button). Anyways...
Sample function with parameter:
function foo(bar){
return bar;
}
calling the script in a cell
=foo('hello world')
returns me hello world
as expacted
Signing this to my button
foo('hello world')
causes an error because the button cant find the script. He's searching for a function name foo('hello world')
but (...)
has non to do with the function.
So how can I pass params when signing script?
At the moment I have 26 functions (all the same, only 1 param changes) to solve this. But with passing a parameter I could do all this with 2 functions instead of 26.
You can't pass parameters when using a custom function via assigning it to a drawable image. It only works when the custom function is called from a cell.
Possible workarounds is to store your parameters on certain sheets and cells then retrieve them via
getRange()
and getDisplayedValue()
.
Other possible workarounds are posted in a Google product help forum which can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With