I'm using the following method to encode URLs in Google Sheets:

How do I convert a cell to RFC 3986 standard (URLEncoded) in Google Spreadsheets?

It works. The only problem is – when I apply it to a sheet with 6000 entries – it gives ERRORs. As far as I understand this is due to too many requests. One of the help messages suggested trying to set in delays.

How can I do this?


To set up a delay on the execution of a Google Apps Script use sleep(milliseconds).

The above will work between code sentences not if a formula is repeated thousands of times.

It's very likely that you should try to convert your custom function from one that returns a single value into one that is able to get and return array of values. See Optimization


Not the most elegant solution but I used the script cache as a mutex of sort to prevent too much executions in parallel. I'm sure some must execute at the same time but few enough to not be a problem for me.

// Entry point of the function
var cache = CacheService.getScriptCache();
var last = cache.get('running');
while (last  != null) {
  last = cache.get('running');
cache.put('running', '_', 1); // This data will be cached for just 1 second

If the functions wait too much due to the long queue they will timeout.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.