Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to have a Google Workspace Add-on homepageTrigger multiple times? #435

Open
catmanjan opened this issue Dec 13, 2023 · 0 comments
Open
Assignees

Comments

@catmanjan
Copy link

catmanjan commented Dec 13, 2023

We have a Google Workspace add-on that operates via a sidebar, so we use homepageTrigger so that the user can open the sidebar from the right hand menu.

This works well - but only once per page load - so if the user opens the sidebar, closes it and attempts to reopen via the right hand menu we instead get this page:

bEMcc

How instead can we have the homepageTrigger function run every time?

Here is the appsscript.json:

{
  "timeZone": "Australia/Sydney",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "dependencies": {
    "enabledAdvancedServices": [
      {
        "userSymbol": "Drive",
        "serviceId": "drive",
        "version": "v2"
      }
    ]
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/documents.currentonly",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/presentations",
    "https://www.googleapis.com/auth/script.container.ui",
    "https://www.googleapis.com/auth/drive",
    "https://www.googleapis.com/auth/drive.apps.readonly",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.locale",
    "https://www.googleapis.com/auth/userinfo.email"
  ],
  "urlFetchWhitelist": [
    "https://cm234-wgs-1.icognition.cloud/",
    "https://docs.google.com/feeds/download/documents/export/Export",
    "https://docs.google.com/spreadsheets/export",
    "https://docs.google.com/feeds/download/presentations/Export"
  ],
  "addOns": {
    "common": {
      "name": "Content Manager",
      "logoUrl": "https://cm234-wgs-1.icognition.cloud/CMServiceApiGoogle/TrimIcon/W64h64/trim.png",
      "homepageTrigger": {
        "runFunction": "showSidebar",
        "enabled": true
      }
    },
    "sheets": {},
    "docs": {},
    "slides": {}
  }
}

Here is the function it is calling (when I add a log line at the start of this function it is only ever called once):

function showSidebar() {
  var sidebarName = "sidebar";

  if (getRecordUri() !== 0) {
    sidebarName = "existing_record_sidebar";
  }

  var ui =
    HtmlService.createHtmlOutputFromFile(sidebarName).setTitle(
      "Content Manager",
    );
  getUi().showSidebar(ui);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants