vendredi 30 octobre 2015

GAS Spreadsheet avoid getting duplicates by marking as "SENT", not working?

so I have this script in Google Spreadsheet and it fetches all the rows marked "READY" just fine, then it sets the value in column "W"(23) to "SENT", and then I am trying to avoid fetching duplicates, by marking the column as "SENT" but then when I run the code again, it ignores the "SENT" that it just pasted? What is wrong here?

var ss = SpreadsheetApp.openById("12y85GmJ94s6k3213j2nGK8rFr0GOfd_Emfk8WHu_MUQ");
var stitchSheet = ss.getSheetByName("Sheet8");
var orderSheet = ss.getSheetByName("Sheet1");

var SENT = "SENT";

function getOrders() {

var range  = orderSheet.getDataRange();
var orders  = range.getValues();  

for (var i = 1; i < orders.length; i++) {
var row = orders[i];
var status = row[1];
var order = row[4]; 
var name = row[5]; 
var system = row[22]; 

if(system != SENT){ 
  if(status.toString() === 'READY'){
orderSheet.getRange(i,23).setValue(SENT);
stitchSheet.appendRow([order,name]); 
}}
}
}

Aucun commentaire:

Enregistrer un commentaire