On Load highlight Client Script for SC_TASK not highlighting

lindac
Kilo Explorer

Hi,

I have created the following On Load client script. The table is sc_task and the field I want to highlight is Request For. The Request For is actually on the Request table and we just reference it on the sc_task table. I am trying to have the Label and Field highlight to Red if the name in the Request for field is a VIP. I am not getting anything highlighted.

I have tried dot walking as shown below and I have tried just using sc_task.requested_for and nothing seems to work.

I have also tried this on the sc_request as a test to see if I could get it to work since on the Request table the Requested For field is not referenced but it still does not work.

The bulk of this client script was taken from an OOB On Change rule for incident called Highlight VIP Caller which is working. I don't need an On Change client script for the sc_task because the Request For field will not change once the request has been created.

Thank you for any assistance that is provided.


function onLoad() {
//get the requested for object so we can access fields
var reqfor = g_form.getReference('request_item.request.requested_for');
var reqforLabel = document.getElementById('label.request_item.request.requested_for');
var reqforField = document.getElementById('sys_display.request_item.request.requested_for');
//check for VIP status
if (reqfor.vip=='true') {
//style object is CSSStyleDeclaration, style names are not standard css names
// if (reqforLabel)
document.getElementById('label.request_item.request.requested_for').style.backgroundColor='red';
//change the requested for's name field to red text
// if (reqforField)
document.getElementById('sys_display.request_item.request.requested_for').style.color='red';
}
else {
//not a VIP, remove temporary styles
// if (reqforLabel)
document.getElementById('label.request_item.request.requested_for').style.backgroundColor='';
// if (reqforField)
document.getElementById('sys_display.request_item.request.requested_for').style.color='';
}
}

11 REPLIES 11

I did have to play around with the backgroundPosition parameters to get the icon positioned properly (Eureka).   That's why mine are different from your 95% 55%.


mithunshah
Kilo Explorer

Hi Guys,



I'm trying to replicate this on our incident_task form - highlight VIP users in the caller ID field, but it's not working.



I tried to edit the out-of-the box highlight VIP on Incident, but couldn't get that to work and I've tried the below, and that hasn't worked either:



function onLoad() {


var reqfor = g_form.getReference('u_incident_task.incident.caller_id');


var reqforLabel = document.getElementById('label.u_incident_task.incident.caller_id');


var reqforField = document.getElementById('sys_display.u_incident_task.incident.caller_id');


if (reqfor.vip == 'true'){


  document.getElementById('label.u_incident_task.incident.caller_id').setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: "95% 55%"});


  document.getElementById('sys_display.u_incident_task.incident.caller_id').style.color='red';


}else {


  document.getElementById('label.u_incident_task.incident.caller_id').style.backgroundImage='';


  document.getElementById('sys_display.u_incident_task.incident.caller_id').style.color='';


}


}




Any ideas?



Thanks



Mithun