1

google.script.run allows a client script to call a function on the server.

But how do I run a script function on the client side from Google Apps Script?

Ruediger Jungbeck
  • 2,836
  • 5
  • 36
  • 59
  • Can you explain more about what you are trying to accomplish? While server side code can't directly invoke any client-side functions, there may be other ways to solve your problem. – Mogsdad Jun 25 '15 at 21:38
  • @Mogsdad for example your famous **poll** friend ;-) ? http://stackoverflow.com/questions/24773177/how-to-poll-a-google-doc-from-an-add-on – Serge insas Jun 25 '15 at 22:36

1 Answers1

0

There's no native way, you'll have to constantly check the GAS for something, eg:

var lastReturn;
setInterval(checkChange, 500);

function checkChange(){
   google.script.run.withSuccesshandler(functionToGetAReturnedValue).functionInGSThatWillReturnAValue();
}

function functionToGetAReturnedValue(whatReturned){
   if(whatReturned !== lastReturn){
      doSomething();
      lastReturn = whatReturned;
   }
}
Kriggs
  • 3,731
  • 1
  • 15
  • 23