Search code examples
user-interfacegoogle-apps-scriptweb-applicationsshared-libraries

Is there any way to call a library from a client side user interface?


I'm building a user interface in HTML Service for Google Apps Script and I want to be able to call functions from a library that is loaded in the server side .gs file of my script. The client side call to the server side library does not seem to work. Is this possible to do?

I'm pretty new to javascript/apps script so excuse me if I'm mis-stating what's happening here.

UPDATE: Here's the solution I used

On the container bound script:

function libraryHandler(functionName){
  return eval("libraryIdentifier." + functionName);
}

In the library:

google.script.run.libraryHandler('myLibraryFunctionName(param1,param2,etc.)')

Solution

  • Make a "dummy" function in the same script where the html is. Make that dummy call your library function.