The CreatorCon Call for Content is officially open! Get started here.

Highlight VIP Users

john_roberts
Mega Guru

A customer recently asked for a better way to quickly identify VIP users from the incident form without having to add the VIP field to the form. She wanted to somehow apply a style to the caller label or field. I couldn't figure out how to use 'Personalize Styles' based on other field values so I used a client script. Since onChange events are fired onLoad this works when opening an existing incident as well.

There's an example of modifying the label and value styles.

New incident client script, onChange of caller.



function onChange(control, oldValue, newValue, isLoading) {

//wait until there is a valid record in the field
if (newValue) {

//get the caller object so we can access fields
var caller = g_form.getReference('caller_id');

//check for VIP status
if (caller.vip=='true') {

//change the caller label to red background
//style object is CSSStyleDeclaration so style names are not standard css names
document.getElementById('label.incident.caller_id').style.backgroundColor='red';

//change the caller's name field to red text
document.getElementById('sys_display.incident.caller_id').style.color='red';
}
else {
//not a VIP, remove temporary styles
document.getElementById('label.incident.caller_id').style.backgroundColor='';
document.getElementById('sys_display.incident.caller_id').style.color='';
}
}
}
Great idea, thanks Amie.

5 REPLIES 5

Not applicable

How would you change this script to allow it to just look for the caller NOT look for a change to the caller. So if the Caller is set to a person it will auto flag it as a VIP.


Tannia,
Not sure if I follow your requirement. The onChange event will also run with you load the incident form with a user already populated even though the user field is not changed.


This doesn't seem to be working for me. I have added the VIP field to the Users form and set one of the Users, ITIL_TEST, as a VIP. I have then created a new client script called Highlight VIP and pasted the code. Finally, I opened an Incident and selected ITIL_TEST as the Caller, but the field was not highlighted in Red. I went back to the script and changed the Type from onChange to onLoad, to no avail. Have I missed a step?


Not applicable

Ignore my previous post, I was being dim. Sorted it out by adding 'Caller' to Field Name