Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Jim Coyne
Kilo Patron

Unlike the VIP flag, a user may be assigned to multiple computers. How do you want to handle that scenario? Show the flag if any of the computers is of a certain manufacturer?


Hello Jim,

In fact you're right, a user can be assigned multiple computers.
In my case, we can imagine a simple status field for the equipment with primary, secondary... values
and my condition need to match that computer must be a primary equipment.

Hope I'm clear


Hichem
Mega Expert

Does someone knows how it is possible to do that please ?

Thanks in advance


Hichem
Mega Expert

Hello all,

Is what I'm asking impossible to do ?

Thanks for any help