title: Update a row in google sheets based on duplicate
body: <p>I'm designing a script that takes an object (<code>jsonData[data]</code>) and inputs its values into a different sheet based on which product it is.</p>
  
  <p>Currently the script inputs all the data into a new row each time the form reaches a new stage, however the form goes through 4 stages of approval and so I'm finding each submission being entered into 4 different rows. Each submission has an "Id" value within the object which remains the same (but each submission could also be on any row in the sheet as it's used a lot).</p>
  
  <p>I'm checking whether the ID exists in the sheet and using iteration to find the row number:</p>
  
  <pre><code>function updatePlatformBulkInfo(jsonData) {  
    var sheetUrl = "https://docs.google.com/spreadsheets/d/13U9r9Lu2Fq1WTT8pQ128heCm6_gMmH1R4O6u8e7kvBo/edit#gid=0"; 
    var sheetName = "PlatformBulkSetup";  
    var doc = SpreadsheetApp.openByUrl(sheetUrl);  
    var sheet = doc.getSheetByName(sheetName);
    var rowList = [];
    var formId = jsonData["Id"];
    var allSheetData = sheet.getDataRange().getValues();
    setLog("AllSheetData = " + allSheetData[1][11]) //Logs to ensure data is collected correctly
    var rowEdited = false;
    var rowNumber = 0;
  
    //Check whether ID exists in the sheet  
    for (var i = 0; i &lt; allSheetData.length; i++) {
      if(allSheetData[i][11] == formId) {
        rowEdited = true;
      } else {
          rowNumber += 1;        
      } 
    }
  </code></pre>
  
  <p>My issue is with the next part:</p>
  
  <pre><code>//Append row if ID isn't duplicate or update row if duplicate found
  if (rowEdited == false) {
    for (var data in jsonData) {
      rowList.push(jsonData[data])
    } 
    setLog("***Row List = " + rowList + " ***");
    setLog("***Current Row Number = " + rowNumber + " ***");
    sheet.appendRow(rowList); 
  } else if(rowEdited == true){
    var newRowValue = jsonData[data];
    sheet.getRange(rowNumber, 1).setValues(newRowValue);
  }
  </code></pre>
  
  <p>Everything works fine if the duplicate isn't found (the objects values are appended to the sheet). But if a duplicate is found I'm getting the error: </p>
  
  <blockquote>
    <p>Cannot find method setValues(string)</p>
  </blockquote>
  
  <p>This looks to me like i'm passing a string instead of an object, but as far as I'm aware I've already converted the JSON string into an object:</p>
  
  <pre><code>var jsonString = e.postData.getDataAsString();
  var jsonData = JSON.parse(jsonString);
  </code></pre>
  
  <p>How can I modify my script to write the updated data to the matched row?</p>