CI based on location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 07:53 AM
Hello,
I want to bring all the CI´s based on location. On the incident form if a user select a location then all CI´s need to be filtered by that specific location. I have created a script include and I am calling with a reference qualifier on the Configuration Item field but for some reason its not working:
client callable
script include
var SevenEleven_CI_ReferenceQuali = Class.create();
SevenEleven_CI_ReferenceQuali.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getConfigurationItems: function(ci_id) {
// if (!ci_id)
// return;
gs.log("Business Service ID: " + ci_id);
// Set up return value
var returnList = '';
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ci_id);
ci_gr.query();
while (ci_gr.next()) {
if (returnList == '') {
returnList += ci_gr.location.sys_id;
} else {
returnList += ',' + ci_gr.location.sys_id;
}
}
// gs.log("Return List: " + returnList);
// Return the values
return returnList;
},
type: 'SevenEleven_CI_ReferenceQuali'
});
Reference qualifier:
javascript:new SevenEleven_CI_ReferenceQuali().getConfigurationItems(current.location);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 12:29 PM
just tested and it passes the sys id and it gives me a list of sys_id of ci. but not really sure why it doesnt make the filtering

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 12:43 PM
Try this approach.
script include (name: getConfigurationItems)
function getConfigurationItems() {
var ticket_location = current.location; //get location from ticket form
var returnList = '';
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ticket_location);
ci_gr.query();
while (ci_gr.next()) {
if (returnList == '') {
returnList += ci_gr.sys_id;
} else {
returnList += ',' + ci_gr.sys_id;
}
}
return returnList;
}
Reference qualifier:
javascript:getConfigurationItems();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 12:55 PM
no sir it doesnt work. i was closer with the other approach

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 12:54 AM
I think the reason is you return sysids while you should return qualifier.
script include (name: getConfigurationItems)
function getConfigurationItems() {
var ticket_location = current.location; //get location from ticket form
var returnList = 'sys_idIN';
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ticket_location);
ci_gr.query();
while (ci_gr.next()) {
if (returnList == 'sys_idIN') {
returnList += ci_gr.sys_id;
} else {
returnList += ',' + ci_gr.sys_id;
}
}
return returnList;
}
Reference qualifier:
javascript:getConfigurationItems();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 08:28 AM
Mark the answer as correct and helpful if it helped you..!!
Tested the below code in background script and working fine
Reference Qualifier
javascript:new SevenEleven_CI_ReferenceQuali().getConfigurationItems(current.location);
Script Include --> Client callable should be unchecked
getConfigurationItems: function(ci_id) {
var returnList = [];
// Get the Category Structures
var ci_gr = new GlideRecord('cmdb_ci');
ci_gr.addQuery('location', ci_id);
ci_gr.query();
while (ci_gr.next()) {
returnList.push(ci_gr.location)
}
return returnList.toString();
},