title: Error when using importhtml function in script
body: <p>I am trying to use the google sheets function <code>importhtml()</code> in a script, to pass an encoded query parameter.</p>
  <pre><code>function recode(query) {
  const value = encodeURIComponent(query).replace('%20','+');
   var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.getRange('A3').activate();
    spreadsheet.getCurrentCell().setFormula('=importhtml(&quot;xxx.com/?query='+value+'&quot;,&quot;table&quot;,1)');
  
  }
  </code></pre>
  <p>I get an error &quot;Exception: You do not have permission to call setFormula (line 5).'</p>