I'm trying out my first Google Sheets Apps Script. I'm trying to make a custom function (via a bound script) that will check if the cell it's in is protected. If it is protected, it should change the cell's value to (for now at least) the protection type.
I can successfully run the simple demo script in the docs:
function DOUBLE(input) {
return input * 2;
}
But when calling Range::protect, I can an error
"You do not have permission to call protect"
Here's the function
function isProtected() {
var range = SpreadsheetApp.getActiveRange();
var protection = range.protect();
return protection.getProtectionType();
}
I also get the same permissions error with some other functions, e.g. Session.getEffectiveUser()
.
I figured that since this is a bound custom function and I'm the (only) sheet owner, I'd be able to call these methods. What am I missing? Thanks.
I've tried copy-pasting the script into the script editor of a new sheet, since some posts have had luck with that, but no luck for me.