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-29-2018 10:26 AM
I wanted a script include as the CI field should be based on Location and on business service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 10:47 AM
OK, how are your CIs related to Business Services then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 11:08 AM
basically its like this:
CI’s are tied to an Asset Type. so they added added a reference field called Business Service to the Asset Type record. so i can walk dot CI to Asset Type to Business Service to get the relationship.
so if user select a location and a business service they should get a CI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 12:05 PM
OK, then the following classless or on-demand function could be used:
Name: u_someCustomFunctionName
Client callable: unchecked
Script:
function u_someCustomFunctionName(businessService, location) {
//initialize
var referenceQualifier = [];
//add the Business Service to the filter if specified
if (businessService) {
referenceQualifier.push("u_asset_type.u_business_service=" + businessService);
}
//add the Location to the filter if specified
if (location) {
referenceQualifier.push("location=" + location);
}
gs.addInfoMessage(referenceQualifier.join("^")); //comment this line out later, just to show you how the filter changes based on what is selected
return referenceQualifier.join("^");
}
Then use the following "Reference qual":
javascript:u_someCustomFunctionName(current.business_service, current.location);
You could also use the same code but create the Script Include with a class as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 01:21 PM
business services are not directly tied up to CI.
there is a class within cmdb called 'facilities' (sys_class_name) inside that record there is a reference field called assets type and inside that record there is a field called business service.
basically for any class different than facilities the Configuration Items should shows the one with the location field. which is working.
but if its facilities (class) then it should show configuration items on the incident form based on location and business service.
not really sure if this makes sense to you. but this is the requirement