- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 11:24 PM
I have below Catalog client script which calls the script include. I'm getting the answer as null
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue) {
return;
}
var answer_json = [];
var gaj = new GlideAjax('x_113476_managed_c.getCiClass');
gaj.addParam('sysparm_name','getPrimaryCiClass');
gaj.getXML(ajaxResponse);
function ajaxResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer) {
answer_json = answer.evalJSON();
//alert(answer_json);
}
}
var collectorName = 'CIs';
var filterString = 'sys_class_nameIN'+answer_json;
try{
var myListCollector = g_list.get(collectorName);
myListCollector.reset();
myListCollector.setQuery(filterString);
}
catch(e){
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(filterString);
window[collectorName + 'acRequest'](null);
}
}
//}
Script include
var getCiClass = Class.create();
getCiClass.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
initialize: function() {
},
getPrimaryCiClass : function()
{
gs.addInfoMessage('calling script include');
var strCiClass = '';
var arrConfigItemClass = [];
var grPrimaryCiClass = new GlideRecord('x_113476_managed_c_managedciclass');
grPrimaryCiClass.addActiveQuery();
grPrimaryCiClass.addQuery('primary_ci_class',true);
grPrimaryCiClass.query();
while (grPrimaryCiClass.next())
{
strCiClass = grPrimaryCiClass.ci_class;
arrConfigItemClass.push(strCiClass.toString());
}
return arrConfigItemClass;
},
type: 'getCiClass'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 05:31 AM
Hi,
remove initialize() function from that client callable script; it is not required; remove this and it should work
If you want to make a script "Client callable", you can't have "initialize" function.
initialize: function() { },
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎07-31-2019 07:31 PM
I'm getting the output as org.mozilla.javascript.NativeArray@1750d6e when logged
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 07:53 PM
I see arrConfigItemClass is an array. Try returning it as a String to the client side. Either use JSON to stringify it or maybe just join the array with "," before returning:
return arrConfigItemClass.join(",")

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 07:55 PM
try doing
return arrConfigItemClass.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 08:33 PM
I got the output, did the same.... I want to apply same to the filter..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 08:37 PM