Highlight VIP caller

sid23
Mega Contributor

Hi Everyone,

As we know, that we have an OOB feature called "Highlight VIP Employee" used in incident form or hr case forms. We have a requirement to have the same functionality which is - " In the list view have VIP icon/image beside the opened_by field on chat records.(This i was able to achieve, by assigning a new style to it and it worked). When i open a chat record i want to highlight the person's name in the "opened_by" field to "Red color" as we see on the incident or hr case forms. I have applied a client script - 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
g_form.getReference('opened_by',setColor);
}
function setColor(openedby) {
var openedbyField = g_form.getElement('sys_display.' + g_form.getTableName() + '.opened_by');
if (openedby.vip == 'true')
openedbyField.setStyle({color : "red"});
else
openedbyField.setStyle({color : ""});
}

 

But its not working. Any suggestions?

26 REPLIES 26

I tried this script but it gave me this error, any suggestions on this ?
I need to create a custom field called "on behalf of" on incident table and make it behave exactly like "caller" behaves(VIP flag & red colour) if VIP user is selected.


onChange script error: TypeError: $ is not a function function () { [native code] }

 

ShubhamB9308858_0-1742383179117.png

 

nayanawadhiya1
Kilo Sage

Use Field Styles.

why are you using Client Script?

OOB Feature uses Field Styles.

Define Field Styles

find_real_file.png

 

Thanks Nayan,

I have used the same functionality as you've posted there in the screenshot for styling. But when i open the record i want to highlight the opened_by field in red color if the person is VIP. Do you have any suggestions?find_real_file.png

sid23
Mega Contributor

PFA

Over the last few versions of ServiceNow, I'm not sure when it started, the Style for VIP doesn't work on the form. You need a corresponding client script to do the work.  There's an out of the box one on Incident called "Highlight VIP Caller".  You also have to make sure that the Client Script property "Isolate script" is set to false.  It's not on the form, so you either have to add it there, or just add it to the list and edit it there.