为什么代码有时会从自身触发?

时间:2019-06-22 12:45:42

标签: google-apps-script

为什么我的代码的错误率很高,有时我发现它是由自身触发的?我使用onEdit触发器来触发代码,代码的工作是使日历事件符合价值。

image to the error rate

function myFunction() {


    var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Timesheet & Feedback");
    var cell = ss.getActiveCell();
    var cellContent = cell.getValue();
    var Manaf = CalendarApp.getCalendarById("manaf652@gmail.com");
    var MustafaSmeer = CalendarApp.getCalendarById("8q65ner19m8uk8idmmkmrr2hvs@group.calendar.google.com");
    var MustafaAli = CalendarApp.getCalendarById("p0vh7m02jjpajr71j08jur3kic@group.calendar.google.com");
    var Abdulla = CalendarApp.getCalendarById("agigdlg1b80fs60938ir1f8q6c@group.calendar.google.com");
    var MustafaAnees = CalendarApp.getCalendarById("0uct5pjadt8r6lbj9642ac05ts@group.calendar.google.com");
    var activeRow = ss.getActiveCell().getRow();
    var data = ss.getRange("A"+activeRow+":G"+activeRow).getValues()[0];

    var start = data[2]
    var end   = new Date(start)
    end.setHours(start.getHours()+2);

    var startt = data[4]
    var endd   = new Date(startt)
    endd.setHours(startt.getHours()+2);

    var starttt = data[6]
    var enddd  = new Date(starttt)
    enddd.setHours(starttt.getHours()+2);

    if(cellContent === "Manaf") {



    Logger.log(data);
    Manaf.createEvent(data[0],start,end,{description: "First call "+ data[0]}) ; 
    Manaf.createEvent(data[0],startt,endd,{description: "Second call "+ data[0]}) ;     
    Manaf.createEvent(data[0],starttt,enddd,{description: "Third call "+ data[0]}) ;
    }


    };

0 个答案:

没有答案