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:53 PM
I need it with a script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 08:39 PM
Why is that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 01:09 AM
this works fine for me. Thank you Jim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 07:33 AM
You are welcome. Remember to mark any response as being helpful. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 08:16 AM
There are a number of ways to handle this:
1. A simple "Advanced" Reference Qualifier
Set the "Use reference qualifier" to "Advanced" and set the "Reference qual" field to "javascript:"location=" + current.location;"
This is really the simplest way of doing it.
2. A classless Script Include Function
Set the "Use reference qualifier" to "Advanced" and set the "Reference qual" field to "javascript:u_someCustomFunctionName(current.location);"
Then create a Script Include with the following details:
Name: u_someCustomFunctionName
Client callable: unchecked
Script:
function u_someCustomFunctionName(location) {
return "location=" + location;
}
Simple, but the first one is simpler.
3. Class-based Script Include
Set the "Use reference qualifier" to "Advanced" and set the "Reference qual" field to "javascript:new SevenEleven_CI_ReferenceQuali().getConfigurationItems(current.location);"
Then create a Script Include with the following details:
Name: SevenEleven_CI_ReferenceQuali
Client callable: unchecked
Script:
var SevenEleven_CI_ReferenceQuali = Class.create();
SevenEleven_CI_ReferenceQuali.prototype = {
initialize: function() {
},
getConfigurationItems: function(location) {
return "location=" + location;
},
type: 'SevenEleven_CI_ReferenceQuali'
};
The big problem with the answers above is that only the sys_ids were being returned and NOT the entire filter (e.g. sys_id=list of ids). The platform did not know what you wanted to do with the list.