How can we show the VIP flag for the "Requested for" field on the form?

Bill_Ymr_61
Mega Guru

We have been asked to show the VIP flag for requests, similar to what shows for incidents.  We have been able to create a style that shows the VIP gif in the list, but we are having trouble getting the gif to show on the forms.  Below is the client script that we tried to use, but still not getting the gif to show.

We are currently using London Patch 4

This is the form of the script:

find_real_file.png

This is the script:

function onLoad() {

   var callerLabel = $('label.sc_req_item.request.requested_for');
   var callerField = $('sys_display.sc_req_item.request.requested_for');
   if (!callerLabel || !callerField)
   return;

   /*if (!newValue) {
   callerLabel.setStyle({backgroundImage: ""});
   callerField.setStyle({color: ""});
   return;
   }*/

   g_form.getReference('request.requested_for', vipCallerCallback);
}

function vipCallerCallback(caller) {

   var callerLabel = $('label.sc_req_item.request.requested_for').down('label');
   var callerField = $('sys_display.sc_req_item.request.requested_for');
   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(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
   //set callerField color
   callerField.setStyle({color: "red"});
   } else {
   callerLabel.setStyle({backgroundImage: ""});
   callerField.setStyle({color: ""});
   }
}

Allen Andreas
Tera Patron

Hi,

Couldn't you just copy (insert) the current VIP style and client script for Incident? But just choose the RITM table and Requested for field respectively?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Tried that first, but it does not work either.

dvp
Mega Sage

If the instance in upgraded to London, Disable Isolate script field on client script

https://community.servicenow.com/community?id=community_blog&sys_id=c5c46364dbba6b007d3e02d5ca9619cb

We are in London, patch 4. 

I added the field, tried it checked and unchecked, still getting the same result.