So, I am brand new to app scripts. Like only the last 30 minutes and I only need it to do one thing. Copy info from one workbook to another and append it when new data is added to a cell. So far I have this:
function onEdit(e) {
var sh=e.range.getSheet();
if(e.range.columnStart==8 && e.range.rowStart==8 && sh.getName()=="Land") {
var sss = SpreadsheetApp.openById('Worksheet ID'); //replace with source ID
var ss = sss.getSheetByName('Sheet Name'); //replace with source Sheet tab name
var range = ss.getRange('A2'); //assign the range you want to copy
var data = range.getValues();
var tss = SpreadsheetApp.openById('Worksheet ID'); //replace with destination ID
var ts = tss.getSheetByName('Test 2'); //replace with destination Sheet tab name
ts.getRange(ts.getLastRow()+1, 1).setValues(data); //you will need to define the size of the copied data see getRange()
}else{
return;
}
}
However, it needs permission to run, and because it can only be run by the trigger I can't give it permission. So I added a test function and ran it in debugger and it worked perfectly and asked me for permission. I granted it permission and tested it again by changing the data in the cell H8. This led to the same error of not having permission. Here is my test function in case you want to know:
function test_onEdit() {
onEdit({
user : Session.getActiveUser().getEmail(),
source : SpreadsheetApp.getActiveSpreadsheet(),
range : SpreadsheetApp.getActiveSpreadsheet().getActiveCell(),
value : SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getValue(),
authMode : "LIMITED"
});
}
I am sure that there is probably a simple solution to this, but I defiantly do not know it. Thanks in advance for any help!