[英]How can I assign a function to a button in google script
I created a prompt in google script, with two buttons. 我在Google脚本中创建了一个带有两个按钮的提示。 If clicked OK, I want a function to run, if not, a dialog says "The user clicked no". 如果单击“确定”,则我希望某个功能运行,否则,对话框将显示“用户单击否”。 The buttons are generated correctly, and the function works. 按钮正确生成,并且该功能起作用。 I know this, 'cause I know how to assign it to an item menu. 我知道这一点,因为我知道如何将其分配给项目菜单。
makefile is the function I'm trying to run makefile是我要运行的功能
function AFIP() {
var ui = SpreadsheetApp.getUi()
var response = ui.alert('Title', 'Yo want to generare the file?',
ui.ButtonSet.OK_CANCEL);
if (response == ui.Button.OK) {
makefile;
} else {
Logger.log('The user clicked "No" or the close button in the dialog\'s title bar.');
}
}
Using this for the definition of the makefile function: 使用它来定义makefile函数:
function makefile() {
Logger.log("makefile() has been executed.");
}
Your code works, with one change. 您的代码可以工作,只需更改一下即可。 Instead of: 代替:
makefile;
It should be: 它应该是:
makefile();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.