Not getting the answer from Script Include in onSubmit Catalog Client Script by using GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:09 AM
Hi,
Can anyone tell me that where am I going wrong. I am getting the null answer. Please refer the below scripts and screenshots.
Script Include:
var UserAuthorizationToFormSubmission = Class.create();
UserAuthorizationToFormSubmission.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkAuthorization : function(){
var userId = this.getParameter('sysparm_user_id');
return "userId";
},
type: 'UserAuthorizationToFormSubmission'
});
Client Script:
function onSubmit() {
var current_user = g_user.userID;
var auth_stat = new GlideAjax('UserAuthorizationToFormSubmission');
auth_stat.addParam('sysparm_user_id', current_user);
auth_stat.addParam('sysparm_name', 'checkAuthorization');
auth_stat.getXMLWait();
alert(auth_stat.getAnswer());
}
Output:
Please suggest why this is happening if I am trying to get the value from the script include which is client callable and called from the above mentioned client script by using the 'getXMLWait()' method.
Thanks,
Ankit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:27 AM
Hi,
The issue is that you are doing this in an onSubmit client script.
The GlideAjax function is running async, so by the time when the script has done the processing, the onSubmit script is already completed.
That's why you get a Null answer, the data is still not returned, and the value not defined.
You should switch to using an onChange client script to have the processing be completed before the submit happens.
Also, don't use "getXMLWait()" you should explore the getXMLAnswer() instead.
Mark Roethof has written a great article on it, you can find it here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 06:50 AM
what's your business requirement here?
If you want to do some validation then please use onChange rather than onSubmit
remember these points:
1) Asynchronous GlideAjax won't work as by the time ajax function returns the value your form will get submitted
2) Synchronous GlideAjax is not allowed in portal and scoped application
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
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 11:09 PM - edited 05-12-2025 11:11 PM
Hi,
Here's the requirement:
I have a Catalog Item form that includes auto-populating and read-only fields like Name, Manager, etc. The Manager field gets auto-filled based on the Name whenever the form loads.
Now, I want this Catalog Item to be Submitted by :
The Manager of the user auto populated in the form.
Two static users defined in a system property.
Please let me know how we can implement this logic or if you need any further details.
Thanks,
Ankit