[英]Can a script edit a protected range or sheet?
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.
}
That depends, yes, a script is able to edit a protected range, what matters is who runs the script. 是的,这取决于脚本能够编辑受保护的范围,重要的是谁来运行脚本。 The person (account) running the script must have edit permission on the protected range.
运行脚本的人(帐户)必须对受保护范围具有编辑权限。 If the account running the script does not have edit permission on the protected range then the code will throw an exception.
如果运行脚本的帐户对受保护范围没有编辑权限,则代码将引发异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.