0

So I have a very useful script which goes through a lot of my Google Documents and merges them into a single pdf. The problem is - it takes minutes to run! I want to add a doGet() function, but the GET request times out before the code is done. Is there a way that I return some HTML to the user yet also run the script?

Or is there a different approach?

My idea was to serve a page to the user, saying: "Your file will be done in a minute. Once it's done you will be able to view it here", but replace the "here" with a URL to a different GAS which would either display the file if it is done or display "You might have to wait a bit" if it isn't yet. I do know how to achieve that.

But how can I call the script which creates the file and also show some output to the user? Both of these when a user enters some GAS, calling a doGet() function.

Tank you in advance

  • You can use triggers to perform a function every 7 minutes, so that you can split up the task. You can use scriptProperties for example to store it in memory for the next function to run. An alternative is to create two spreadsheets with an "deploy as web app" url, and then let the one script activate the other via UrlFetchApp to the URL of the other web app, and back every 6 minutes. I would recommend the first idea though. – Wim den Herder Feb 28 '17 at 21:09
  • 1
    Here is a similar Stack Overflow question: [Link - exceeded max exec time](http://stackoverflow.com/questions/7854573/exceeded-maximum-execution-time-in-google-apps-script) – Alan Wells Feb 28 '17 at 21:21

0 Answers0