Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

var value is not passing to function without first showing an "alert()"

Avatar

Level 2

I am retrieving a value from a form 

var programName = xfa.resolveNode("form1.page1.subApprovedTrainingNAC.subEd[" + oWrapper.index + "].educationInstance.lstPrograms").rawValue; 

 

when I attempt to pass it to my function

callRestService(url,lstPrograms,programName);

the function receives it as null

However if in between the two statesments I have

alert("programName before click call: " + programName);

then the value is received correctly.

How can I get value to the function with the value without showing the alert?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Since setting the time out on the callRestService didn't work, I wound up using

var programName = xfa.resolveNode("form1.page1.subApprovedTrainingNAC.subEd[" + oWrapper.index + "].educationInstance.lstPrograms").rawValue;

var myTO = app.setTimeOut("var site = programName; app.clearTimeOut(myTO) ;", 5000) ;

 

Then sent the call as before

callRestService(url,lstPrograms,programName);

 

and it is now working

View solution in original post

0 Replies

Avatar

Community Advisor

Hi,

 

If the value is coming correctly only with alert then it is because by the time callRestService the value is not populating to programName variable. With alert you are buying sometime for variable to populate before passing to method.

 

Try adding timeout then it will work fine without alert or make the calls as sync instead of async

 

Hope this helps !

Avatar

Level 2

I tried this

var myTO = app.setTimeOut("callRestService(url,lstPrograms,programName)",5000) ;

but function is not responding.

Avatar

Correct answer by
Level 2

Since setting the time out on the callRestService didn't work, I wound up using

var programName = xfa.resolveNode("form1.page1.subApprovedTrainingNAC.subEd[" + oWrapper.index + "].educationInstance.lstPrograms").rawValue;

var myTO = app.setTimeOut("var site = programName; app.clearTimeOut(myTO) ;", 5000) ;

 

Then sent the call as before

callRestService(url,lstPrograms,programName);

 

and it is now working