VIP Tag Not Displaying for "Owned By" Field on CMDB CI Record when user is VIP
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi,
Hi Community,
I am trying to display the VIP tag for the Owned By field on the cmdb_ci table, similar to how the VIP indicator is displayed for the Caller field on the Incident table.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var callerLabel = $('label.cmdb_ci.owned_by');
var callerField = $('sys_display.cmdb_ci.owned_by');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('owned_by', vipCallerCallback);
}
function vipCallerCallback(owner) {
var callerLabel = $('label.cmdb_ci.owned_by')
var callerField = $('sys_display.cmdb_ci.owned_by');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (owner.vip == true || owner.vip == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
Has anyone implemented a similar requirement on the cmdb_ci table? Is there any OOB functionality available for displaying VIP indicators on fields other than Caller, or are there any additional configurations required for reference fields such as Owned By?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
48m ago
HI @SivaPrasadR3900 ,
update the client script with following changes:
1.Inherited:true
2.Isolate script:false
3.Use the following script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var tableName = g_form.getTableName(); // dynamic - resolves to cmdb_ci_server, cmdb_ci_computer, etc.
var callerLabel = $('label.' + tableName + '.owned_by');
var callerField = $('sys_display.' + tableName + '.owned_by');
if (!callerLabel || !callerField)
return;
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('owned_by', vipCallerCallback);
}
function vipCallerCallback(owner) {
var tableName = g_form.getTableName();
var callerLabel = $('label.' + tableName + '.owned_by');
var callerField = $('sys_display.' + tableName + '.owned_by');
if (!callerLabel || !callerField)
return;
var labelEl = callerLabel.down ? (callerLabel.down('label') || callerLabel) : callerLabel;
if (owner.vip == true || owner.vip == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
labelEl.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
labelEl.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
