Google Add-On for Sheets launches on refresh

62 Views Asked by At

I am currently in the process of releasing and publishing an Add-On for Google Sheets. Upon Google's review of the add-on, they indicated that the add-on would auto-launch whenever the sheets is refreshed.

How can I change my code so it passes Google review?

EDIT:

    function onOpen() {

    var DocObject = PropertiesService.getDocumentProperties().getProperties();
    //paid = "true" if bought. paid = "false" if not bought. These 
    //are strings not bool values
    var paid = DocObject.Bought;

    if(paid) 
    {
        SpreadsheetApp.getUi().createMenu('aPLM')
       .addItem('Open Menu', 'showMenu')
       .addToUi();
    } else 
    {
        SpreadsheetApp.getUi().createMenu('aPLM')
        .addItem('Start Registration', 'noTrial')
        .addItem('Open Menu', 'showMenu')
        .addToUi();
    }
  }
1

There are 1 best solutions below

1
On

As the comments indicate you most likely have a function called onOpen(). This will result in you script running whenever the user opens a Google Spreadsheet.

As recommended look at changing your script to run when a menu item is selected. Have a look at the below documentation for adding menus to a spreadsheet.

https://developers.google.com/apps-script/guides/menus