How to use asynchronous GlideAjax in on submit client script for validation?

Ravish Shetty
Tera Guru

Hello all,

We have a on submit client script which uses synchronous GlideAjax. As per ServiceNow's recommendations, we are making it asynchronous. The concern is that as below, we are waiting at line 4 for a response from the server and based on it we are either allowing the form to submit or not.

If we replace the synchronous logic with asynchronous, there will not be any waiting at line 4 and the form will be submitted without the validation taking place.

var ga = new GlideAjax('HelloWorld');

ga.addParam('sysparm_name','helloWorld');

ga.addParam('sysparm_user_name',"Bob");

ga.getXMLWait();

if(ga.getAnswer() != ''){

return true;

} else {

return false;

}

Edit: This is a catalog client script

10 REPLIES 10

richardchadd
ServiceNow Employee
ServiceNow Employee

Please note that getXMLWait is not supported in   context of the Service Portal:



Supported and unsupported client scripts