Making the VIP name red in a task table Requested for field.

raj99918
Tera Contributor

Hi Team,

 

I want to make the Requested for field for VIP names in red on a task table , but reqested for is not the direct field on TASK table how can i achieve it by using the client scrip.

 

Note: Requested for on sc table field info: Dictionary Info: sc_task.request_item.requested_for

 

Thanks.

 

16 REPLIES 16

Yes @Ankur Bawiskar , and am writing this onload script on SC task table. Below is my script.

 

function onLoad() {
    var requestedForLabel = $('label.sc_task.request_item.requested_for');
    var requestedForField = $('sys_display.sc_task.request_item.requested_for');
    if (!requestedForLabel || !requestedForField)
        return;
   
    if (!newValue) {
        requestedForLabel.setStyle({backgroundImage: ""});
        requestedForField.setStyle({color: ""});
        return;
    }

g_form.getReference('requested_for', viprequestedForCallback);
}

function viprequestedForCallback(requestedFor) {
    var requestedForLabel = $('label.sc_task.request_item.requested_for').down('label');
    var requestedForField = $('sys_display.sc_task.request_item.requested_for');
    if (!requestedForLabel || !requestedForField)
        return;
   
    //check for VIP status
    if (requestedFor.vip.toString() == 'true') {
        var bgPosition = "95% 55%";
        if (document.documentElement.getAttribute('data-doctype') == 'true')
            bgPosition = "5% 45%";
           
        requestedForLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
        requestedForField.setStyle({color: "red"});
    } else {
        requestedForLabel.setStyle({backgroundImage: ""});
        requestedForField.setStyle({color: ""});
    }
}
 
Note: Requested for on sc table field info: Dictionary Info: sc_task.request_item.requested_for

Hi @Ankur Bawiskar Now am getting the the VIP icon for VIP user but the name is not coming in red color. How can I get it ?

 

Thanks

@raj99918 

try to check the html element id

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar  Sorry I didn't get you Kindly correct me what I have done wrong in my above script.

 

Thanks

Hi @Ankur Bawiskar Kindly help me on this above code am getting the VIP icon for VIP users but Requested for value still is not in red color.