是否可以在Google Apps脚本中调用
setTimeout或同等功能?
当我尝试运行以下代码时:
function onSubmit() {
// we've been called,remove trigger,set timeout,re-enable,and then run function
destroySubmitHandler();
setTimeout(function() {
createSubmitHandler();
myFunction()
},5 * 1000)
}
我收到以下错误:
解决方法
显然你可以像这样使用
Utilities.sleep()功能:
function onSubmit() {
// we've been called,and then run function
destroySubmitHandler();
Utilities.sleep(5 * 1000)
createSubmitHandler();
myFunction()
}