简体   繁体   中英

How to: publish Google apps script Sheets Add-on privately to my domain

I am trying to publish a Google apps script Sheets Add-on.

In the editor the complete 'Directions' submenu is added to the Add-ons menu.

This is the submenu:

Directions >  
  Prepare sheet...   
  Generate step-by-step... 

But when the add-on is published and a new spreadsheet is opened,
the 'Directions' submenu is added to the Add-ons menu,
but the 2 items are not added to the 'Directions' submenu. and there is an error message:

Error Exception: You do not have permission to perform that action. at onOpen(Code:10:36)

I have:

  1. configured Google Workspace Marketplace SDK: visibility private
  2. configured and published a Store Listing
  3. followed the App URL to Install the Add-on to my domain

Code.gs

function onOpen() {
  SpreadsheetApp.getUi()
    .createAddonMenu()
    .addItem('Prepare sheet...', 'prepareSheet_')
    .addItem('Generate step-by-step...', 'generateStepByStep_')
    .addToUi();
}

/**
 * A function that adds headers and some initial data to the spreadsheet.
 */
function prepareSheet_() {}

/**
 * Creates a new sheet containing step-by-step directions between the two
 * addresses on the "Settings" sheet that the user selected.
 */
function generateStepByStep_() {}

You need to use the method addSubMenu(menu)

See also Custom Menus in Google Workspace .

Sample:

function onOpen() {
  var ui = SpreadsheetApp.getUi()
  ui
  .createAddonMenu()
  .addSubMenu(ui.createMenu('Prepare sheet...')
              .addSubMenu(ui.createMenu('Generate step-by-step...')
                          .addItem("Help", 'generateHelp_')))
  .addToUi();
}

在此处输入图像描述

Note:

When you publish your Add-on, Google will add an additoinal default Help menu to the Add-on menu - in addition to your Help menu that is nested inside of Generate step-by-step... .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM