My script is supposed to move a row from one google spreadsheet to another based on a value in a cell. It fails to do so, and I think it's because of the onEdit() function but can't figure it out. I found a solution for different sheets in the same spreadsheet but not in different spreadsheets. My code is below.
function onEdit(e) {
var sss = SpreadsheetApp.getActiveSpreadsheet();
var ss = e.source.getActiveSheet();
var r = e.source.getActiveRange();
if(s.getName() == "source_sheet" && r.getColumn() == 7 && r.getValue() == "Pavlovo"){
//Get full range of data
var SRange = ss.getRange(1, 3, 1, 5);
//get A1 notation identifying the range
var A1Range = SRange.getA1Notation();
//get the data values in range
var SData = SRange.getValues();
// tss = target spreadsheet
var tss = SpreadsheetApp.openById('1_t7BDCWgHJDip_cndzVashxLDQ_pVS6obi3I9TB_EJI');
var ts = tss.getSheetByName('Vitosha'); // ts = target sheet
//set the target range to the values of the source data
ts.getRange(A1Range).setValues(SData);
}
}