To be concrete, I think that the method .protect for sheet objects is not working, I have a code that adds a protection to a sheet triggered by a custom menu function, the code was working perfectly until yesterday that throws an exception , my code is something like this
function setProtection(fila){
if(fila == undefined){
do{
//check some conditions
}while(isNaN(fila) || fila == undefined || fila<4);
}
var link = bitacora.getRange(fila, 5).getValue();
console.log('Este es el link: '+link) //I put logs just to see where does the code was stopping
var id = link.split('/')[5]
var protection = SpreadsheetApp.openById(id).getSheets()[0].protect();
console.log('Se obtuvo la proteccion');
var me = Session.getEffectiveUser();
console.log(me)
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
console.log('Terminé de modificar la protección')
protection.addEditor(//add someone);
}
The thing is that the function stops now at the line:
var protection = SpreadsheetApp.openById(id).getSheets()[0].protect();
So I tried to see if it had something to do with permissions or anything else, but I am the owner of the file that I am trying to edit, the odd thing is that the protection is indeed set but then there is an exception that is thrown: "Service error: Spradsheets"
So I tried to isolate the problem on a new function just trying to set a protection in another sheet
var protection = SpreadsheetApp.openById(randomFileId).getSheets()[0].protect();
The problem persists, does anyone knows how to solve this?
Thank you in advance