- Question I have 3 scripts running on my spreadsheet. Only one is working now. I will post the code below. Only one of the functions are working. 2 of the codes are timestamps and one is an edit Auto Archive code.
I have attached a photo of the 3 scripts I have. One is named Code.gs, archive.gs, Date for Date Removed.gs
Function below not working
function onEdit(event) {
// assumes source data in sheet named main
// target sheet of move to named Completed
// getColumn with check-boxes is currently set to column 1 or A
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "ACTIVITY REPORT" && r.getColumn() == 1 && r.getValue() == true) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Archive");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}
2nd function not working
function onEdit(e){
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sh=ss.getActiveSheet();
if(sh.getName()!='Archive')
return;
var rg=sh.getActiveCell();
if(rg.getRow()<=1)
return;
if(rg.getColumn()!=11)
return;
SpreadsheetApp.flush();
if(rg.getValue()=='NP CND A ACCEPTED' || rg.getValue()== 'NP BACKGROUND')
rg.offset(0, 16).setValue(new Date());
}
3rd Function that is working
function onEdit(){
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sh=ss.getActiveSheet();
if(sh.getName()!='Archive')
return;
var rg=sh.getActiveCell();
if(rg.getRow()<=1)
return;
if(rg.getColumn()!=11)
return;
SpreadsheetApp.flush();
if(rg.getValue()=='NP CND A ACCEPTED' || rg.getValue()== 'NP BACKGROUND'|| rg.getValue()== 'HIRED INTERN-SP' || rg.getValue()== 'HIRED SDR-SP' || rg.getValue()== 'HIRED' || rg.getValue()== 'HIRED INTERN' || rg.getValue()== 'HIRED SDR' || rg.getValue()== 'HIRED SDR' || rg.getValue()== 'NP AS' || rg.getValue()== 'NP LDR' || rg.getValue()== 'NP CND A AR' || rg.getValue()== 'NP CND A OFFER' || rg.getValue()== 'NO SHOW' || rg.getValue()== 'NP ORL' || rg.getValue()== 'NP CND A Zoom Int' || rg.getValue()== 'NP CND A 1 FL')
rg.offset(0, 14).setValue(new Date());
}
Here is the screenshot of the error I am getting when implementing the code a different way. It says unexpected token in line 9.