Thursday, 15 July 2010

Apps Script: Passing a callback to ServerHandler's callback -



Apps Script: Passing a callback to ServerHandler's callback -

i have login form in google spreadsheet allows me login external application. spreadsheet allows me continuously communicate external application can task1, task2 , on it. need verify whether i'm logged in external application before can either task1 or task2.

so utilize case :

user invokes task1 my code checks whether logged in. if not, brings login form. the form first checks login, calls task1. later in future, user invokes task2. my code needs check same scenario 1 time again bring login form. again form checks user's login credentials , time invokes task2.

here's how code looks :

function invoketask1() { //if user not logged in loginform("performtask1"); //else performtask1();//works fine. }

my loginform looks this:

function loginform(scallbackfn) { //code create uiinstance , populate username , password fields //for now, tried hidden field storing callback me. var hdncallback = app.createhidden("executeafterlogin", scallbackfn).setname("proceedwithexecution"); //then have serverhandler ok button click var handler = app.createserverhandler('okbuttonevent'); handler.addcallbackelement(abcpanel); btnok.addclickhandler(handler); }

then okbuttonevent 1 check login , perform corresponding task:

function okbuttonevent(e) { //code pick out e.parameter values , check login on external server application //i don't know how invoke e.parameter.proceedwithexecution here. //this has failed run without errors though. eval(e.parameter.proceedwithexecution); }

and lastly, have these:

function performtask1()//and performtask2() { //doing something. not getting invoked via login form's serverhandler. }

try this[e.parameter.proceedwithexecution]();

this isn't uiapp question per se though - that's how invoke function string name in javascript.

google-apps-script

No comments:

Post a Comment