Client Script - Highlight Config Item

MrMK
Tera Contributor

Hi All.

 

I am trying to highlight the configuration item within the INC form utilising the VIP code from OOTB adjusted to  what I need but to no avail. I need this very simple, if CI is configured as Tier 1 then highlight it in red when selected in INC form.

 

I was able to have the "Style" working in the list using the below, which works fine.

 

javascript: current.cmdb_ci.u_service_tier == 'Tier 1'

 

For the Client Script in the INC table I am using the below, there are no errors but it just won't highlight the CI that has a Tier 1 selected in Service Tier dropdown.

 

Thanks in advance!

********************************************************

 

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

var ciLabel = $('label.incident.cmdb_ci');

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

if (!ciLabel || !ciField) {

return;

}

 

if (!newValue) {

ciLabel.setStyle({backgroundImage: ""});

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

return;

}

g_form.getReference('cmdb_ci', CITier1Callback);

}

 

function CITier1Callback(cmdb_ci) {

var ciLabel = $('label.incident.cmdb_ci');

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

if (!ciLabel || !ciField) {

return;

}

//check for Tier 1 status

if (cmdb_ci.u_service_tier == 'Tier 1'){

 

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

 

}else{

ciLabel.setStyle({backgroundImage: ""});

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

}

}

1 ACCEPTED SOLUTION

For this version of the script to work you would need to have a field on the incident table and form named cmdb_ci_appl that is a reference to the cmdb_ci_appl table.

View solution in original post

5 REPLIES 5

For this version of the script to work you would need to have a field on the incident table and form named cmdb_ci_appl that is a reference to the cmdb_ci_appl table.