Add flag next to the user field

Hichem
Mega Expert

Hi all,

I'm trying to add a small flag next to user field in the incident form depending on the manufacturer of the computer assigned to him (cmdb_ci table).
I'm trying to do something pretty simple, based on the VIP flag which is shown when a user is marked as VIP.
The difficulty here is that the condition is based on a value from a different table.

Here is the var that should be used => var manufacturerLabel = $('label.cmdb_ci.manufacturer');

but I've tried to change this original (Highlight VIP Caller) Code Snippet without success

================
function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;

if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('caller_id', vipCallerCallback);
}

function vipCallerCallback(caller) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;

//check for VIP status
if (caller.vip == 'true') {
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: "95% 55%"});
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
================

Does anyone knows a workaround to do this ?

Thanks

10 REPLIES 10

Hello Jim,

to be honnest I'm still trying to modify the code you gave me to to what I want but without success 😕