当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Set Timeout in Google Apps Scripts

问题描述:

Is it possible to call setTimeout or an equivalent function in Google Apps Scripts?

When I try to run the following code:

function onSubmit() {

// we've been called, remove trigger, set timeout, re-enable, and then run function

destroySubmitHandler();

setTimeout(function() {

createSubmitHandler();

myFunction()

}, 5 * 1000)

}

I get the following error:

网友答案:

Apparently you can use the function Utilities.sleep() like this:

function onSubmit() {
  // we've been called, remove trigger, set timeout, re-enable, and then run function
  destroySubmitHandler();
  Utilities.sleep(5 * 1000)
  createSubmitHandler();
  myFunction()
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: