Incident - Reference Qualifier for business service and CI

r_t_bryan
Kilo Expert

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.

1 ACCEPTED SOLUTION

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'


};


View solution in original post

4 REPLIES 4

Michael Fry1
Kilo Patron

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;


}


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'


};


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

santhi2
Kilo Contributor

I Am also facing same issue only  show active CI  in the business service/ci field..how to use the dictionary over ride