Adding a flag to a CI

olivershields
Kilo Explorer

Hi,

We have identified a number of CIs that are to be listed as "High Impact" CIs via a true/false box that we have added to all classes.

I am wondering if there is a way to make these CIs stand out when entered into a 'Primary CI' or 'Affected CI' field on changes and incidents respectively, if this field is ticked. Similar to the warning indicator that comes up when a CI is selected that is currently affected by another task.

Thanks

1 ACCEPTED SOLUTION

Community Alums
Not applicable

You can certainly do this.



It is easy to do for the list view, and simply uses a style. With your field created, from any incident, right-click the header and select Personalize > All. Then go to the Styles tab and create a new style on the Configuration Item field. Set the value to javascript:current.cmdb_ci.u_high_impact == true (adjust this to reflect your actual field name). Then define the style you want to apply. Perhaps a background color change or something else.



It is a little trickier to make the CI stand out on the form. For that you will need a Client Script. There is already something similar that you can use as an example and modify: the Highlight VIP Caller Client Script does something like what you want, but for the Caller field.



Here is a script you can drop in. You need to adjust the field name to match your actual High Impact field (indicated in bold below).



function onChange(control, oldValue, newValue, isLoading) {


  var ciField = $('sys_display.incident.cmdb_ci');


  if (!ciField)


  return;



  if (!newValue) {


  ciField.setStyle({color: ""});


  return;


  }


  g_form.getReference('cmdb_ci', highImpactCICallback);


}




function highImpactCICallback(ci) {


  var ciField = $('sys_display.incident.cmdb_ci');


  if (!ciField)


  return;



  //check for High Impact status


  if (ci.u_high_impact == 'true') {


  ciField.setStyle({color: "red"});


  } else {


  ciField.setStyle({color: ""});


  }


}


View solution in original post

10 REPLIES 10

Community Alums
Not applicable

You're welcome. Happy to help.