1

This is just...bizarre...

I'm running a function with a user that does have full Edit access to the Sheets in question.

This code:

function test() {
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('importDailyOrders');
  
  var column = sheet.getRange("A1:A");
  // Plain text
  column.setNumberFormat("@");
 
  var sheet = ss.getSheetByName('orderSummary');
  var data = sheet.getRange("A2").getValue();
}

...gives me this error

Exception: You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit. (line 11, file ...

But commenting out the setNumberFormat allows the function to run.

Note that the code works fine for the Sheet owner. This error only happens when running the script by a different user.

Is this a bug? If not...what's happening?

1 Answer 1

3

Oh geez, the error message totally misled me. The problem was with the column.setNumberFormat("@"); on the other because that tab was protected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.