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 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: ""});


  }


}


Hi Ben,



Thanks for the help but i cant seem to get it to work.



I have used the script you provided for the value and amended it to the field name (same as yours only with an _ci after it). I have even just used 'background-color:tomato' as the style to try and get it working but when i put a CI in the box that has the High Impact CI field ticked it does nothing.



Is there something else i need to check?



Thanks


Community Alums
Not applicable

Can you post a screen shot of the Client Script record you created? That might be easier than trying to ask through all the possibilities.


SN1.pngThis is the customer field thats been created on the CI table



SN2.pngThis is the style that i have setup. Hoping that this turns the field red (or tomato?) when a CI is put into it that has the above field ticked.



Dont quite know what you mean by Client Script (forgive my scripting ignorance) but hope this covers it.



Thanks