I have a WebApp which takes some values from a google sheet when it is opened. I want to store a global variable so that I do not have to make a call to the server all the time
The easiest way is store it as a global variable:
var TEST;//Declare global
google.script.run.withSuccessHandler(yourCallBack2).getPNInfo(body);
function yourCallBack2(pinfo) {
console.log("callback called");
TEST = pinfo[0];//set global
}
function updateQ(){
var ea = TEST;//get global
console.log(ea);
}
Other ways to persist information would be to use
google.script.run
is a async call. So, updateQ
might run before yourCallBack2
and your global variable TEST
may be undefined
by then.