var value is not passing to function without first showing an "alert()" | Community
Skip to main content
jeanetter358457
Level 2
December 7, 2021
Solved

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

  • December 7, 2021
  • 1 reply
  • 867 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jeanetter358457

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

1 reply

Ravi_Pampana
Community Advisor
Community Advisor
December 8, 2021

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 !

jeanetter358457
Level 2
December 8, 2021

I tried this

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

but function is not responding.