I'm using a script to copy and paste some data with is filled by a couple of users without permission to edit only one line, the others ranges are protected from edit by these users.
The script copies the data from one sheet to another and both sheets are entirely protected, except by two editors who can edit anything. This same script is triggered on a time-based trigger when no one is working on this spreadsheet.
The question is: A script is able to edit a protected sheet or range?
Here is the code (just in case):
function CopyDaily() {
var ss = SpreadsheetApp.openById('1olKDp').getSheetByName('Produtos vendidos'); //Seleciona a planilha DE ONDE os dados devem ser copiados
var sss= SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos'); //Seleciona a planilha PARA ONDE os dados devem ser copiados
var LastRow1 = SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos').getLastRow() + 1;
var LastRow2 = SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos').getLastRow() + 6;
Logger.log(ss.getName());
ss.getRange('A2:S7').copyTo(sss.getRange('A' + LastRow1 + ':S' + LastRow2), {contentsOnly:true})
}
function addTrigger() {
var everyDay = ScriptApp.newTrigger("CopyDaily")
.timeBased() //Define o tipo da trigger: Baseada em hora.
.everyDays(1) //Frequencia de dias: a cada 1 dia.
.atHour(12) //Em qual hora: 1 am.
.create(); //Cria a trigger baseada nos parametros acima.
}