- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2026 06:27 AM - edited 07-02-2026 09:02 AM
I'm trying to convert List Collector sys_ids to user names using GlideAjax. The List Collector returns comma-separated sys_ids, which I pass to a client-callable Script Include. However, the GlideAjax response is always null.
Script include
var getwatchlistusernames = Class.create();
getwatchlistusernames.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getName: function() {
var ids = this.getParameter('sysparm_ids');
var names = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'IN', ids);
gr.query();
while (gr.next()) {
names.push(gr.getValue('name'));
}
return names.join(',');
},
type: 'getwatchlistusernames'
});
Catalog Client script
var ga = new GlideAjax('getwatchlistusernames');
ga.addParam('sysparm_name', 'getName');
ga.addParam('sysparm_ids', g_form.getValue('user'));
ga.getXMLAnswer(callback);
function callback(response) {
alert(response);
// g_form.setValue('short_description', response);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2026 03:33 AM - edited 07-06-2026 04:10 AM
Hi @NishmithaS ,
i looked into the your both script include and catalog client script. i have made one change in script include function name and it worked in my PDI
Script include:
var getwatchlistusernames = Class.create();
getwatchlistusernames.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getNames: function() { // getName changed to getNames
var ids = this.getParameter('sysparm_ids');
var names = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'IN', ids);
gr.query();
while (gr.next()) {
names.push(gr.getValue('name'));
}
return names.join(',');
},
type: 'getwatchlistusernames'
});
Catalog client script:
var ga = new GlideAjax('getwatchlistusernames');
ga.addParam('sysparm_name', 'getNames');// from getName to getNames
ga.addParam('sysparm_ids', g_form.getValue('user'));
ga.getXMLAnswer(callback);
function callback(response) {
alert(response);
// g_form.setValue('short_description', response);
}
can you try this and let me know still your getting null as the resposne
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2026 05:39 AM
plz try debugging your script that everything working fine..
var getwatchlistusernames = Class.create();
getwatchlistusernames.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getName: function() {
var ids = this.getParameter('sysparm_ids');
gs.info('sysparm_ids received: ' + ids);
if (!ids) {
gs.info('ids param is null/empty');
return '';
}
var names = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'IN', ids);
gr.query();
while (gr.next()) {
names.push(gr.getValue('name'));
}
gs.info('names found: ' + names.join(','));
return names.join(',');
},
type: 'getwatchlistusernames'
});
also in client script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;
gs.log('newValue (List Collector):', newValue);
var ga = new GlideAjax('getwatchlistusernames');
ga.addParam('sysparm_name', 'getName');
ga.addParam('sysparm_ids', newValue);
ga.getXMLAnswer(callback);
function callback(response) {
var status = response.responseXML ? 'XML received' : 'NO XML';
gs.log('response status:', status);
if (response.responseXML) {
var answer = response;
gs.log('answer value:', answer);
alert(answer);
} else {
gs.log('full response object:', response);
}
}
}
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2026 02:54 AM
Hi @yashkamde
Thanks for your reply.
I already checked the Client callable checkbox. It is checked.
The Script Include name and function name are the same.
Both the Script Include and Client Script are in the Global scope, but it is still returning null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2026 03:38 AM
Things to check
1) is your script include client callable
2) if script include & client script are in different scopes then is your script include accessible from all scopes? Did you invoke script include with complete API name
screenshots please
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2026 04:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2026 04:17 AM
share your complete script include code here and complete client script code
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader