function testslipupdate(){
var psheet=SpreadsheetApp.openById("1O2-xzPCjQO0cj_6LjehFnKmmTL519gXEpRYwRoEwIFA").getSheetByName("testslip");
var msheet=SpreadsheetApp.openById("1yLXRoV4MH6p_5F6rX3MnGnruDQVr4dqK-6GhRjRv3ns").getSheetByName("students");
var lrow = psheet.getLastRow();
var testID = psheet.getRange(lrow,2).getValue();
var uemail = psheet.getRange(lrow,3).getValue();
var slip = psheet.getRange(lrow,4).getValue();
var data = msheet.getDataRange().getValues();
var dtlen = data.length;
for(var i =1; i<data.length;i++){
if(data[i][0] == testID && data[i][2]==uemail){
msheet.getRange(i+1,20).setValue(slip);
break;
}
//else if(data[i][0]==testID && data[i][2]!==uemail){
else if(data[i][2]!==uemail){
MailApp.sendEmail(""+uemail+"","Email address is not matched with Test ID","","Please change to valid email address");
break;
}
//else if(data[i][0]!==testID){
else {
MailApp.sendEmail(""+uemail+"","Record not found","","Please see Principal for a new registration.");
break;
}
}
}
function ll(a,b) {
Logger.log(a + ": " + b)
}
for(var i =1; i<data.length;i++){
ll('data[i][0]',data[i][0])
ll('data[i][2]',data[i][2])
ll('data[i][0] == testID',data[i][0] == testID)
ll('data[i][2] == uemail',data[i][2] == uemail)
Array.prototype.findIndex())
for a question raised in StackOverFlow which we can refer via below link:-
function testslipupdate(){
var psheet=SpreadsheetApp.openById("1O2-xzPCjQO0cj_6LjehFnKmmTL519gXEpRYwRoEwIFA").getSheetByName("testslip");
var msheet=SpreadsheetApp.openById("1yLXRoV4MH6p_5F6rX3MnGnruDQVr4dqK-6GhRjRv3ns").getSheetByName("students");
var lrow = psheet.getLastRow();
var testID = psheet.getRange(lrow,2).getValue();
var uemail = psheet.getRange(lrow,3).getValue();
var slip = psheet.getRange(lrow,4).getValue();
var data = msheet.getDataRange().getValues();
var dtlen = data.length;
var qrow = data.findIndex(qID=> {return qID[0] == quoteID});
var mrow = data.findIndex(mailID=> {return mailID[2] == uemail});
var mqrow=qrow+1;
var mmrow=mrow+1;
if(mqrow==0){
MailApp.sendEmail(""+uemail+","Record not found","","Please see Principal for a new registration.");
}
else if(mqrow!=0&&mmrow==0){
MailApp.sendEmail(""+uemail+","Email address is not matched with Test ID","","Please change to valid email address");
}else{
msheet.getRange(mqrow,20).setValue(slip);
}
}
It doesn't seem like you are using dtlen. You only set it, but I don't see it used anywhere.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/2533da4b-9785-4248-8f55-f7ad631c92ecn%40googlegroups.com.
Sahar Weinberg E-Success co-founder & Owner | |
Mobile: +972543110840 Gmail: Saha...@gmail.com | |