1

I have a script on Google Sheets that works fine from a menu. The script is designed that when I select a certain cell, then run the script using the menu choice I created, it uses an HTML template to create a form, and the results of that form create content for that cell. I would like to simplify the process and use the 'onSelectionChange' trigger to see if they selected that cell. When I use that trigger to call the script, on the last line of this section:

const template = HtmlService.createTemplateFromFile('selDialog');
template.optionsData = getPlayers();
const html = template.evaluate();
SpreadsheetApp.getUi().showModalDialog(html, 'Select Players');

I find the error in the Stackdriver logs Exception: You do not have permission to call Ui.showModalDialog. Required permissions: https://www.googleapis.com/auth/script.container.ui

I have searched the error, but I am still unsure how to resolve it. Should I use a different method of displaying the HTML form that I use to collect the data? I have seen the suggestion that perhaps showModalDialog is depreciated. I just find it odd that it works perfectly if I call the script from a custom menu in Sheets rather than using 'onSelectionChange'

Petenewk
  • 11
  • 2
  • are you sure you want to use `onSelectionChange` ? your script will be executed even if you make other irrelevant selections, switch sheets, or select a full column or whatever. – Marios Oct 12 '20 at 14:44
  • 1
    Basically, "Simple" triggers can't access htmlservice. So, you can't do that( even though I proposed a twisted workaround in one of the duplicate answers linked, it still can't be used with htmlservice/ui) – TheMaster Oct 12 '20 at 14:57

0 Answers0