The permissions for custom functions are different than the regular Apps Script code permissions. When using the Spreadsheet service, which includes SpreadsheetApp, it is "Read Only". The clearContent() method is not "read only". It's changing data in the sheet. So even though it's not a "set" method, it's still not "Read Only".
This behavior is described in the documentation at the following link:
A custom function cannot affect cells other than those it returns a
value to. In other words, a custom function cannot edit arbitrary
cells, only the cells it is called from and their adjacent cells. To
edit arbitrary cells, use a custom menu to run a function instead.
you are trying to clear a cell that is not the one containing the function.
Asked in February 2016Viewed 3,838 timesVoted 11Answered 2 times