title: Google apps script impossible to convert undefined in class
body: <p>hi i'm not really into js but tried to run this script:</p>
  
  <pre><code>function doGet(e){
  
    var op = e.parameter.action;
  
    var 
  ss=SpreadsheetApp.openByUrl("xxxxx");
    var sheet = ss.getSheetByName("Catalogati 2018");
  
  
    if(op=="insert")
      return insert_value(e,sheet);
  
    //Make sure you are sending proper parameters 
    if(op=="read")
      return read_value(e,sheet);
  
    if(op=="update")
      return update_value(e,sheet);
  
    if(op=="delete")
      return delete_value(e,sheet);
  
  
  
  }
  
  function getLastNonEmptyCellInRow(oggetto,ss) {
    var sh = ss.getSheetByName("Catalogati 2018");
    var rowToCheck = oggetto;
    var maxColumns = sh.getLastRow();
  
    var row = sh.getRange(rowToCheck, 1, 1, maxColumns).getValues();
    row = row[0]; //Get inner array of two dimensional array
  
    var rowLength = row.length;
  
    for (var i = 0; i &lt; rowLength; i++) {
      var thisCellContents = row[i];
  
      Logger.log('thisCellContents: ' + thisCellContents);
  
      if (thisCellContents === "") {
        Logger.log(i);
        return i + 1;  //Pass the count plus one, which is the last column with data
      }
    }
  }
  
  //Recieve parameter and pass it to function to handle
  
  
  
  
  function insert_value(request,sheet){
    console.log(request);
     var id = request.parameter.id;
    var persona = request.parameter.name;
    var oggetto= request.parameter.oggetto;
    var flag=1;
    var lr= sheet.getLastRow();
    var lc= sheet.getLastColumn();
    console.log(id+persona+oggetto);
    for(var i=1;i&lt;=lr;i++){
      var id1 = sheet.getRange(i, 2).getValue();
      if(id1==id){
        flag=0;
    var result="Id already exist..";
      } }
    //add new row with recieved parameter from client
    if(flag==1){
      var nInv = oggetto+persona;
      var d = new Date();
      var currentTime = 3443//d.toLocaleString();
      var rowData = [[persona,nInv]];
      var range = sheet.getRange(oggetto+7,getLastNonEmptyCellInRow(oggetto,sheet)+1,1,2);
      range.setValues(rowData); 
    var result="Insertion successful";
    }
       result = JSON.stringify({
      "result": result
    });  
  
    return ContentService
    .createTextOutput(request.parameter.callback + "(" + result + ")")
    .setMimeType(ContentService.MimeType.JAVASCRIPT);   
    }
  </code></pre>
  
  <p>and the broswer console returns the error :" impossible to convert undefined in (class). (line 30)"
  this is the line 30:</p>
  
  <pre><code>var rowData = sheet.getRange(rowToCheck, 1, 1, maxColumns).getValues();
  </code></pre>
  
  <p>Probably the error can be in the get and post but i' not sure. this is the script in the html:</p>
  
  <pre><code>function insert_value() {
  
      $("#re").css("visibility","hidden");
       document.getElementById("loader").style.visibility = "visible";
      $('#mySpinner').addClass('spinner');
  
      var id1=    $("#id").val();
      var name= $("#persona").val();
      var oggetto = $("#oggetto").val();
  
      var url = script_url+"?callback=ctrlq&amp;name="+name+"&amp;id="+id1+"&amp;oggetto="+oggetto+"&amp;action=insert";
  
  
      var request = jQuery.ajax({
        crossDomain: true,
        url: url ,
        method: "GET",
        dataType: "jsonp"
      });
  
    }
  </code></pre>
  
  <p>Where is the error? (sorry if the question can result silly but i'm still learning)</p>
  
  <p>the variable oggetto that the html passes with post method comes from this:</p>
  
  <pre><code>&lt;select name "oggetto"&gt;
      &lt;option value = " 1"&gt;1234&lt;/option&gt;
      &lt;option value = " 2"&gt;4321&lt;/option&gt;
      &lt;option value = " 3"&gt;121341&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>p.s. using the console i found that the variables that i pass such as "oggetto" arrives ad undefined. But i on't understand why because the action and the id uses the same method to be sent to the script.</p>