Exceeded maximum excecution time.

Skip to first unread message


Jul 21, 2020, 3:44:08 AM7/21/20
to Google Apps Script Community

Hello! Sorry for the bad language right away (I use a translator). I read many topics with this problem, unfortunately I could not find an answer. The problem is obvious, it takes longer than 6 minutes.
But! I am using this simple script:

simple(name, date) {
const searchSheet = SpreadsheetApp.getActive().getSheetByName(date);
if (searchSheet !== null) {

const names = searchSheet.getRange('B:B').getValues()
const index = [];
.forEach(element => {
if (element[0] === name) index.push(names.indexOf(element) + 1);
if (index.length > 1) return 'две строчки';
if (index.length === 0) return;

const all = searchSheet.getRange(index[0], 3, 1, 4).getValues();

const timeCome = all[0][0];
    let timeEnd
= all[0][1];
const checkTime = all[0][2];
const comment = all[0][3];

if (timeEnd < timeCome) timeEnd.setDate(timeEnd.getDate() + 1);
    let countHours
= (timeEnd - timeCome) / 1000 / 60 / 60;
if (/обед/i.test(comment.toLowerCase())) countHours -= 1;

if (countHours === checkTime) {
return checkTime;
} else {
return 'ОШИБКА'

As you can see, the script is elementary, the problem is that I execute it in each cell XD. It turns out more than a thousand simultaneous executions. And then I see the following picture (wherever Error is - "Exceeded maximum excecution time").

As you can see, only a small part "freezes". the rest are working fine.

Please give advice on how to overcome this. Thank!

Andrew Roberts

Jul 21, 2020, 7:35:46 AM7/21/20
to google-apps-sc...@googlegroups.com
Rather than run it as a custom function, set up a regular clock trigger to run and process the whole sheet in one go.

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/10fc4be7-219f-4885-92ac-f3719f76d213o%40googlegroups.com.


Jul 22, 2020, 4:15:49 AM7/22/20
to google-apps-sc...@googlegroups.com
Please tell us a little more! Do you mean to set up a trigger for example every 10 minutes?
I did it, there have already been several executions, the number of errors has not decreased.

I apologize that the screen is not in English, but I think everything is clear anyway :)
Reply all
Reply to author
Message has been deleted
0 new messages