- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 04:37 AM
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: ""});
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 12:36 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 05:11 AM
Since this script uses DOM ($ shortcut) ensure the isolate script box is unchecked.
Also, ensure that 'Tier 1' is the exact value stored in your u_service_tier field on the CI table (case and space sensitive).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 06:03 AM
Hi.
Yes that has been ticked off, and all spaces there. I am thinking that there is an error somewhere as if I add "red" to the bottom 2
}else{
ciLabel.setStyle({backgroundImage: ""});
ciField.setStyle({color: ""});
}
}
Then it will auto apply red to all, so its almost like not reading the service tier field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 07:30 AM
Trying adding an alert like this to see what it thinks the tier value is
alert('service_tier=' + cmdb_ci.u_service_tier);
and is service_tier a field you added to the cmdb_ci table, or one of the extended tables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 03:20 AM
Thanks - you sent me on the right path, to say our CMDB is a bit of unmanaged mess. When I added the Tier field into a Configuration Item form then this now works as intended. I have previously added the Service Tier field to cmdb_ci_appl table, amended the script but it will not work, not sure where I might be going wrong, amended code below:
Thanks.
function onChange(control, oldValue, newValue, isLoading) {
var ciLabel = $('label.incident.cmdb_ci_appl');
var ciField = $('sys_display.incident.cmdb_ci_appl');
if (!ciLabel || !ciField) {
return;
}
if (!newValue) {
ciLabel.setStyle({backgroundImage: ""});
ciField.setStyle({color: ""});
return;
}
g_form.getReference('cmdb_ci_appl', CITier1Callback);
}
function CITier1Callback(cmdb_ci_appl) {
var ciLabel = $('label.incident.cmdb_ci_appl');
var ciField = $('sys_display.incident.cmdb_ci_appl');
if (!ciLabel || !ciField) {
return;
}
//check for Tier 1 status
if (cmdb_ci_appl.u_service_tier == 'Tier 1'){
ciField.setStyle({color: "red"});
}else{
ciLabel.setStyle({backgroundImage: ""});
ciField.setStyle({color: ""});
}
}