Autopopulating the two list collectors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hi,
I have a scenario where i have two catalog variables, Servers and Applications. Servers is pointing to cmdb_ci_server, while applications pointing to the cmdb_ci_appl tables. Servers selection should autopopulate the Applications. it is autopopulating for 1 selection, but when i select multiple Servers, it is not working. Please make it as simple as possible. Kindly help.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = new GlideAjax('cmdbServer');
gr.addParam('sysparm_name', 'cmdbFunction');
gr.addParam('sysparm_id', newValue);
gr.getXML(callBackFunction);
function callBackFunction(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('application', answer);
}
}
var cmdbServer = Class.create();
cmdbServer.prototype = Object.extendsObject(AbstractAjaxProcessor, {
cmdbFunction: function() {
var abc = this.getParameter('sysparm_id');
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', abc);
gr.addQuery('type.name', 'Runs on::Runs');
gr.query();
while(gr.next()){
return gr.child.name;
}
},
type: 'cmdbServer'
});
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
45m ago - last edited 43m ago
Update your script include script as below. The one you have written works only for one server and moreover, you need to get child CI sys_ids instead of name of the CI.
cmdbFunction: function() {
var childCIs = [];
var abc = this.getParameter('sysparm_id');
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', 'IN', abc);
gr.addQuery('type.name', 'Runs on::Runs');
gr.query();
while(gr.next()){
childCIs.push(gr.child.toString());
}
return childCIs.join(',');
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
38m ago
Hope your variables are list collector. Modify your script include as below
var cmdbServer = Class.create();
cmdbServer.prototype = Object.extendsObject(AbstractAjaxProcessor, {
cmdbFunction: function() {
var abc = this.getParameter('sysparm_id');
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent.sys_id', 'IN', abc);
gr.addQuery('type.name', 'Runs on::Runs');
gr.query();
var returnArr = [];
while(gr.next()){
returnArr.push(gr.child.name.toString());
}
return returnArr.join(",");
},
type: 'cmdbServer'
});
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7m ago
Hi,
It works perfectly. is it possible for us to make the script more easier? I am not that good with scripting.
Regards
Suman P.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2m ago
Hi,
You cant make it simpler than this.
Mark my response as accepted solution since your issue is resolved.
T
Palani