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

Please use the below script exactly without any changes. I just tried in my PDI on the chat table and works great!

 

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

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

callerLabel.setStyle({backgroundImage: "url(vip_user.png)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}

Result:

find_real_file.png

Please hit correct based on impact of response.

Thanks!

 

sid23
Mega Contributor

I don't know why it's not working on my side 

 

 

 

find_real_file.png

sid23
Mega Contributor

This is the script i have included as mentioned - 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
function vipCallerCallback(caller) {
var callerLabel = $('label.chat_queue_entry.opened_by').down('label');
var callerField = $('sys_display.chat_queue_entry.opened_by');
if (!callerLabel || !callerField)
return;

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

callerLabel.setStyle({backgroundImage: "url(vip_user.png)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}}

I'm sorry. Some part of the code was not copied properly. Please find the below updated script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//Type appropriate comment here, and begin script below
var callerLabel = $('label.chat_queue_entry.opened_by');
var callerField = $('sys_display.chat_queue_entry.opened_by');
if (!callerLabel || !callerField)
return;

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

 

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

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

callerLabel.setStyle({backgroundImage: "url(vip_user.png)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}

Please try this and it should work now.

Please hit correct based on impact of response.

Thanks!

sid23
Mega Contributor

Yep i tried the same, i have copy pasted the code you've provided but still no luck. We have the same functionality for general hr case and this is the client script which is being used and it works perfectly fine.

client script for general hr case - 

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