2021年3月26日星期五

Exception: The parameters (null,number) don't match the method signature for SpreadsheetApp.Sheet.getRange. (line 33, file "Code")

I'm a begginer of GAS, now I'm studyng how to coding with this video https://www.youtube.com/watch?v=s-I8Z4nTDak

But my script doen't go well,error message of title pops up,

I'm just following videos code, I have rewrited its tons of times to get it right. but error doen't stop.

I don't know well about GAS yet, what happens ? Where is wrong? How Can I fix it?

Someone Help Me.

var wsOptions = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("options");  var options = wsOptions.getRange(2, 1,wsOptions.getLastRow()-1,3).getValues();  var firstLevelColumn = 1;  var secondLevelColumn = 2;    function myFunction() {      var list = ["a","b","g","a","b","f"];    var cell = ws.getRange("C2");    applyValidtionToCell(list,cell);      }      function onEdit(e){    var activeCell = e.range;    var val = activeCell.getValue();    var r = activeCell.getRow();    var c = activeCell.getColumn();    var wsName = activeCell.getSheet().getName();    if(wsName == "master" && c === firstLevelColumn && r >1){      applyFirstLevelValidation(val,r);       } //close IF   }    function applyFirstLevelValidation(val,r){        if(val === ""){        ws.getRange(r, secondLevelColumn).clearContent();        ws.getRange(r, secondLevelColumn).clearDataValidations();      } else {        ws.getRange(r, secondLevelColumn).clearContent();        var filteredOptions = options.filter(function(o){ return o[0] === val });        var listToApply = filteredOptions.map(function(o){ return o[1] });        var cell = ws.getRange(r, secondLevelColumn);        applyValidtionToCell(listToApply,cell);      }    }      function applyValidtionToCell(list,cell){        var rule = SpreadsheetApp    .newDataValidation()    .requireValueInList(list)    .setAllowInvalid(false)    .build();        cell.setDataValidation(rule);  }```  
https://stackoverflow.com/questions/66828189/exception-the-parameters-null-number-dont-match-the-method-signature-for-spr March 27, 2021 at 01:07PM

没有评论:

发表评论