Highlight VIP user in requested items form as I checked previous solutions didn't work

Aneela Sravani
Tera Contributor

How to highlight VIP user in service request form in requested items I checked same styles and client script in incident and previous solutions nothing worked for my instance . 

Can anyone please respond it is quite urgent requirement 

Thanks in Advance

10 REPLIES 10

DrewW
Mega Sage
Mega Sage

So you have tried this 

https://www.servicenow.com/community/itsm-forum/highlight-vip-caller-in-client-script/m-p/478071

 

And it did not work?

 

Is this for a workspace or the platform UI?  Workspace works differently.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0794200

 

 

Thank you very much for your quick response.

It is not for workspace .

Requirement is to highlight vip user in service request form, using client scripts it is not working as expected and using styles vip icon is visible in list view in request table and same condition not working for requested items table. So Can you please help me with this please.

 

Thank you in advance.

 

So if its not working for the sc_req_item table but is for others then you have something wrong with the style or condition.  I suspect its an issue with the condition but without you posting it there is no way to know.

AneelaSravani_0-1683788257135.png

This is the I had added in styles but vip icon is appearing in list view of sc_req_item table. 

For client script I used this onchange script on requested for filed

function onChange(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.sc_req_item.requested_for');
var callerField = $('sys_display.sc_req_item.requested_for');
if (!callerLabel || !callerField)
return;
 
if (!newValue) {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
return;
}
g_form.getReference('requested_for', vipCallerCallback);
}
 
function vipCallerCallback(requested_for) {
var callerLabel = $('label.sc_req_item.requested_for').down('label');
var callerField = $('sys_display.sc_req_item.requested_for');
if (!callerLabel || !callerField)
return;
 
//check for VIP status
if (requested_for.vip == 'true') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true')
bgPosition = "5% 45%";
 
callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
callerField.setStyle({color: "red"});
alert('User is VIP');
} else {
callerLabel.setStyle({backgroundImage: ""});
callerField.setStyle({color: ""});
}
}
But vip icon is not appeared in requested items form.
And I also tried this onload script with this
function onLoad() {
 
    //alert('User is VIP');
    var caller = g_form.getReference('requested_for', callback);
 
    function callback(caller) {
if(caller.vip=='true'){
alert('User is VIP');
//var labelcolor = document.getElementById('label.request.requested_for');
      //labelcolor.style.color = 'red';
caller.setStyle({color: "red"});
//alert('Requested for is VIP User');
}
//else{
 
// }
      //
// alert(caller.vip==getMessage('User is VIP'));
// if(alert=='true'){
// g_form.showFieldMsg("requested_for", "User is VIP");
// alert("User is VIP");
}
//
       
    }

Using this script only alert is working fine but no styling or vip icon is adding to the form .

Can you please check on this.

Thank you in Advance