服务在短时间内调用了太多次

时间:2017-09-12 03:37:24

标签: javascript

我收到以下脚本的错误消息。 “服务在很短的时间内调用了太多次:exec qps。在两次调用之间尝试Utilities.sleep(1000)。”

我在下面给出了我的代码。你能帮我阻止这个错误信息吗?注意:我正在使用从另一个工作表导入的数组公式。触发器设置为更改。

function onEdit(e) {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName('Direct');
    var range = sheet.getDataRange();
    var values = range.getValues();
    var rows_deleted = 0; 

    for (var i = 0; i < values.length; i++) {
        for (var j = 0; j < values[i].length; j++) {

            var value = values[i][j];

            //row numbers are 1-based, not zero-based like this for-loop, so we add one AND...
            //every time we delete a row, all of the rows move down one, so we will subtract this count
            var row = i + 1 - rows_deleted;

            //if the type is a number, we don't need to look
            if (typeof value === 'string') {

                var result = value.search("Remove");

                //the .search() method returns the index of the substring, or -1 if it is not found
                //we only care if it is found, so test for not -1

                if (result !== -1) {
                    sheet.deleteRow(row);
                    rows_deleted++;
                }
            }  
        }
    }
};

0 个答案:

没有答案