- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 07:44 AM
I am trying to limit the available CI's on an Incident form based on the business service selected. I was thinking of writing a script include to achieve this, and refer to it as a Dictionary override. However, is there an easier way to achieve this? Thanks in advance, Robert.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 03:34 AM
Hi Michael,
I managed to get it working in the end with the following script. Thanks for your help.
P.S. for anyone intending to achieve a similar function, please use a dictionary override when using the reference qualifier, as the CI field is on the task table.
var BusinessService_CI =
{
getCiInBusinessService : function(current){
var retVal = '';
if (current.business_service == ''){
gs.log('no business service');
return;
}else{
var grCmdbRel = new GlideRecord('cmdb_rel_ci');
grCmdbRel.addQuery('parent', current.business_service);
grCmdbRel.query();
while(grCmdbRel.next()){
gs.log('child.sys_class_name = ' + grCmdbRel.child.sys_class_name);
gs.log('child string = ' + grCmdbRel.child.toString());
if(grCmdbRel.child.sys_class_name != "cmdb_ci_service")
retVal += grCmdbRel.child.sys_id + ",";
}
}
return 'sys_idIN' + retVal;
},
type: 'BusinessService_CI'
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 09:55 AM
Script include would work best. Here's example of one to get your started:
function GetDownstreamCIs() {
if (current.business_service == '') {
gs.log('business service is empty');
return;
}
else
gs.log('business service is ' + current.business_service);
var retval = "sys_idIN";
var objRelCI = new GlideRecord('cmdb_rel_ci');
objRelCI.addQuery('parent', current.business_service);
objRelCI.query();
// ADD DOWNSTREAM
while (objRelCI.next()) {
gs.log('child.sys_class_name = ' + objRelCI.child.sys_class_name);
gs.log('child string = ' + objRelCI.child.toString());
if(objRelCI.child.sys_class_name != "cmdb_ci_service")
retval += objRelCI.child.sys_id + ",";
}
return retval;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 03:34 AM
Hi Michael,
I managed to get it working in the end with the following script. Thanks for your help.
P.S. for anyone intending to achieve a similar function, please use a dictionary override when using the reference qualifier, as the CI field is on the task table.
var BusinessService_CI =
{
getCiInBusinessService : function(current){
var retVal = '';
if (current.business_service == ''){
gs.log('no business service');
return;
}else{
var grCmdbRel = new GlideRecord('cmdb_rel_ci');
grCmdbRel.addQuery('parent', current.business_service);
grCmdbRel.query();
while(grCmdbRel.next()){
gs.log('child.sys_class_name = ' + grCmdbRel.child.sys_class_name);
gs.log('child string = ' + grCmdbRel.child.toString());
if(grCmdbRel.child.sys_class_name != "cmdb_ci_service")
retVal += grCmdbRel.child.sys_id + ",";
}
}
return 'sys_idIN' + retVal;
},
type: 'BusinessService_CI'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2018 12:21 PM
Hi Michael,
I'm trying to accomplish the same task, but I'm new to scripting (I'm and analyst being tasked with development). Would you mind walking through the process of making this work? I have created the Script Include, but I'm not sure if I'm calling it correctly. I'm also a confused as to how to use the dictionary override.
Thanks,
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2018 05:37 AM
I Am also facing same issue only show active CI in the business service/ci field..how to use the dictionary over ride