- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 06:16 AM
Hi SNC,
GlideAjax returning null value.
Where i am doing wrong?
Script Include
checkTheExisingPachingRequest: function(AppServiceId, reqStartDate, reqEndDate) {
var appserviceId = this.getParameter('sysparm_Appci') || AppServiceId;
var sDate = this.getParameter('sysparm_reqStartDate') || reqStartDate;
var eDate = this.getParameter('sysparm_reqEndDate') || reqEndDate;
gs.log("appserviceId >> " + appserviceId);
gs.log("sDate >> " + sDate);
gs.log("eDate >> " + eDate);
Catalog Client Script
function onSubmit() {
//Type appropriate comment here, and begin script below
// >> topic >> getting boolen value server_patching_request
var server_patching_request_true_or_false = g_form.getValue('server_patching_request');
var application_choosen = g_form.getValue('application_service');
var start_time_choosen = g_form.getValue('start_timestamp');
var end_time_choosen = g_form.getValue('end_timestamp');
//alert(server_patching_request_true_or_false + " >> " + g_form.getValue('application_service') + " >> " + g_form.getValue('start_timestamp') + " >> " + g_form.getValue('end_timestamp'));
// >> topic >> initiate GlideAjax and pass the above values
var gjx = new GlideAjax('WOWserverbookerUtils');
gjx.addParam('sysparm_name', 'checkTheExisingPachingRequest');
gjx.addParam('sysparm_Appci', application_choosen);
gjx.addParam('sysparm_reqStartDate', start_time_choosen);
gjx.addParam('sysparm_reqEndDate', end_time_choosen);
gjx.getXML(CallBack);
alert(JSON.stringify(gjx));
function CallBack(response) {
var output = response.responseXML.documentElement.getAttribute("answer");
alert(output);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2022 11:46 PM
Update the below line as below and try.
var arrAppServiceID = appserviceId.toString().split(',');
Replaced "AppServiceId" with "appServiceId".
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 06:46 AM
I just noticed that you are using GlideAjax in onSubmit client script that actually doesn't work with getXML (synchronous).
Please have a look at below articles to understand the reason and for making it Asynchronous.
How To: Async GlideAjax in an onSubmit script | Blog
Asynchronous onSubmit Catalog/Client Scripts in ServiceNow
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 07:27 AM
I simply changed type from onSubmit to onChange.
It returns null still.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 09:56 AM
Please update below lines as:
var appserviceId = AppServiceId ? AppServiceId : this.getParameter('sysparm_Appci');
var sDate = reqStartDate ? reqStartDate : this.getParameter('sysparm_reqStartDate');
var eDate = reqEndDate ? reqEndDate : this.getParameter('sysparm_reqEndDate');
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 06:52 AM
Hi,
you are using asynchronous ajax in onSubmit so by the time the ajax function returns value the form might get submitted
Refer these links for solution
Refer these links for workaround/solution on how to use Synchronous GlideAjax in onSubmit
How To: Async GlideAjax in an onSubmit script
Asynchronous onSubmit Catalog/Client Scripts in ServiceNow
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2022 07:11 AM
I tried with = getXMLWait
Still it returns null.
++
Can you help me more on this topic?