How do I display the VIP Icon next to Affected User on Incident Forms?

David M1
Tera Contributor

Hi all. I'm very new to ServiceNow, still configuring for our go live on Kignston.

We have the VIP Caller setup and it works fine for New Incidents. However we also have a field on the form called Affected Person (u_affected_user, reference User (sys_user).

How can I have this field also show the VIP icon and Text Red?

The idea being anyone may log a call for the CEO or other VIP (Affected Person) so we want this highlighted.

I copied the Client Script "Highlight VIP Caller" and pointed it at the Affected Person field but nothing changes.

Any help would be much appreciated.

Thanks

David

1 ACCEPTED SOLUTION

Tushar Sharma2
Kilo Guru

If you have copied the Same Client script then below changes is mandatory in new script.

1.On change client script should be written on u_affected_user. 

2.Replace 'label.incident.caller_id with  'label.incident.u_affected_user'.

3. Replace 'g_form.getReference('caller_id', vipCallerCallback)' with g_form.getReference('u_affected_user', vipCallerCallback).

4.Replace sys_display.incident.caller_id with 'sys_display.incident.u_affeted_user'.

5.In the sys_user form VIP check box should be checked.

 

Hit Helpful or Correct on the impact of response.
-Tushar

View solution in original post

16 REPLIES 16

Hello Naveen,

I tried with your code and your code is working for me.I have just replaced u_manager with my field value.

Check with the User's VIP field value and the 

 

Regards,

Tushar

Hi Tushar,

 

user is VIP. 

I have cross checked it.

Could you please replace your code with below and let me know how many alerts you got and what are the values of alerts.

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

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

function vipCallerCallback(caller) {
alert('loopback');
var callerLabel = $('label.incident.u_manager').down('label');
var callerField = $('sys_display.incident.u_manager');
if (!callerLabel || !callerField)
{
alert("2");
return;
}

//check for VIP status
alert(caller.vip)
if (caller.vip == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";

alert(bgPosition);
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: ""});
}
}

Hi Tushar,

 

I got 3 alerts,

My name,

Loop back

undefined

find_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.png

Actually 4 alerts.