I've exhausted all my options but I just can't seem to get this working =/
My goal is to transfer data from one spreadsheet to another using setValues() because the link feature isn't sufficient for me. I also need to maintain the trigger on edit.
So, I devised a function called AddConvocacao that runs every time there's a change in the sheet.
function addConvocacao(e){
var linha = e.range.getRow(); //get the line number where the edit occurs
var nome = e.source.getActiveSheet().getRange(linha,2).getValue(); //retrieve the field value
var targetSheet = SpreadsheetApp.openById('1iQbZ7iB9ddc-HwLK9vG0eVEeWWqXKJZ0ry7U_Hm4SkQ') //access the other spreadsheet
var targetName = targetSheet.getSheetByName('Pac'); //select the specific tab
var lastRow = targetName.getLastRow(); //determine the last row in the tab
lastRow = lastRow+1; //increment by 1
targetName.getRange(lastRow, 2).setValue(nome); //set the value
// targetName.getRange(lastRow, 3).setValue(valorCol7);
// targetName.getRange(lastRow, 5).setValue(dose);
// targetName.getRange(lastRow, 6).setValue(diagnostico);
// targetName.getRange(lastRow, 7).setValue(medico);
}
Why doesn't it work when I use on edit?
Thank you so much! =)