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

sid23
Mega Contributor

Thanks for your concern.
Here is the script i have included as per your suggestion but still no luck - 

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

var callerLabel = $('label.opened_by');
var callerField = $('sys_display.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.opened_by').down('label');
var callerField = $('sys_display.opened_by');
if (!callerLabel || !callerField)
return;

//check for VIP status
if (opened_by.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: ""});
}


}

 

Am i doing anything wrong?

IS the field name on the client script set to 'Opened by'? Please verify

find_real_file.png

sid23
Mega Contributor

Yes it is opened by

On which table you are trying to execute the code?

Regards!

sid23
Mega Contributor

It;s chat records 

table - chat_queue_entry