3

I am trying to create a 'dashboard' in Google Sheets that can be opened up in a separate window from a button in the sidebar. This dashboard ingests data from a google sheets script. Currently I am struggling to create and serve this page other than to deploy it as a 'web-app'

If I deploy this script as a web-app it creates a new window, with correct htmloutput from my file in the doGet() function, however this dashboard is linked to only the current document and will be the same for other users instead of re-generating the page for different sheets.

Is there a way or work-around to create and serve a webpage, similar to methods such as showSidebar() or showModalDialog() in class UI. I dont really want users to have to publish themselves because it is too much

1
  • I think you covered all of your choices. A WebApp, a dialog or a sidebar. That's it. I think. Commented Sep 21, 2017 at 17:33

1 Answer 1

1

I use this function to return a specific HTML page using a Google web app:

function doGet(e) {
  Logger.log( Utilities.jsonStringify(e) );
  if (!e.parameter.page) {
    // When no specific page requested, return "home page"
    return HtmlService.createTemplateFromFile("index").evaluate().setTitle("Elkhart PD");
  }

  // else, use page parameter to pick an html file from the script
  return HtmlService.createTemplateFromFile(e.parameter['page']).evaluate().setTitle(e.parameter['page']);
}

Start with a dashboard from the main page. Use anchor tags in index.html with their location as follows:

https://script.google.com/a/macros/documentKey1234567/dev?page=extraPage1.html

(Title the page= parameter with the html titles in the project.)

These pages are opened as a standalone HTML page, so you can call the appropriate data using the google.script.run.myFunction() API. The GAS on the backend can pull from any sheet you have access to to serve the appropriate dashboard.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.