Frage

Using a Google Site with an embedded Google Apps Script, I'm displaying some data from a database using JDBC. The Google Apps Script uses doGet to load an HTML page:

function doGet() {
   return HtmlService.createHtmlOutputFromFile('index');
}

...the index.html page in turn calls a function in my Apps Script to get some database data:

google.script.run.withSuccessHandler(mySuccessHandler).getSomeDBData();

When the mySuccesshandler is called, I render the data with the JQuery.

This works. However, embedded Google Apps Scripts have a statically defined height. A post on SO suggested developing a custom Google Gadget which dynamically resizes when content changes.

But I can't find any examples, or confirmation that I can port my current Google Apps Script to my own Gadget. The documentation on working with remote content doesn't mention databases.

I tried placing the call to my App Script in the Gadget XML file:

 google.script.run.withSuccessHandler(mySuccessHandler).getSomeDBData();

However, this failed with cannot call run of undefined. So is there any way I can call a GAS from a custom Google Widget?

War es hilfreich?

Lösung

You cant mix them like that, they are different and disconnected (for example how would the xml gadget know which apps script to call in your attempt?). The easiest would be to use the apps script solely as a data provider like json from a contentService in doGet. From the xml gadget you do an ajax get to the apps script published url & any needed parameters. To avoid auth hassles publish script to run as you with anonymous access.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top