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:
A single execution of Apps script can last no longer than 6 minutes and you're hitting this limit.
If you are running your Apps Script code inside a Gmail account, your functions can run for 6 minutes before it will be terminated. For Google Workspace accounts, because you are paying a monthly fee to Google per user, the timeout limit is more generous at 30 minutes.
On your computer, open a spreadsheet in Google Sheets. Settings. Under "General," click the "Locale" and "Time zone" menus to change your settings. Click Save settings.
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() }
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