Show VIP flag for Requested for on REQUEST, RITM and on task?

AK79
Tera Contributor

Hello Experts,

 

I want to highlight requested for field on request table and Ritm table as well as on Catalog task table. I wrote the Client script but it was not working. Could you please help on this.

function onLoad() {
   var callerLabel = $('label.sc_task.request_item.request.requested_for');
	var callerField = $('sys_display.sc_task.request_item.request.requested_for');
	if (!callerLabel || !callerField)
		return;
	
	/*if (!newValue) {
		callerLabel.setStyle({backgroundImage: ""});
			callerField.setStyle({color: ""});
				return;
			}*/
			
			g_form.getReference('request_item.request.requested_for', vipCallerCallbackREQ);
		}
		
		function vipCallerCallbackREQ(caller) {
			
			var callerLabel = $('label.sc_task.request_item.request.requested_for').down('label');
			var callerField = $('sys_display.sc_task.request_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: ""});
							}
   
}

 

@Ankur Bawiskar @Sohail Khilji 

1 ACCEPTED SOLUTION

Anand Shukla
Mega Guru

Hi ,

You can create a on change Client script for the requested for field and use below script

function onChange(control, oldValue, newValue, isLoading) {
    var callerLabel = $('label.sc_request.requested_for');
    var callerField = $('sys_display.sc_request.requested_for');
    
    if (!callerLabel || !callerField)
        return;
    
    if (!newValue) {
        callerLabel.setStyle({backgroundImage: ""});
        callerField.setStyle({color: ""});
        return;
    }
    g_form.getReference('requested_for', vipCallerCallback);
}

function vipCallerCallback(caller) {
    var callerLabel = $('label.sc_request.requested_for').down('label');
    var callerField = $('sys_display.sc_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' });
        callerField.setStyle({color: "red"});
    } else {
        callerLabel.setStyle({backgroundImage: ""});
        callerField.setStyle({color: ""});
    }
}

View solution in original post

11 REPLIES 11

Patrick Laroch1
Giga Guru

Why are you not simply creating a "Style" for the field similar to this example?

PatrickLaroch1_0-1687185010451.png

 

Hi @Patrick Laroch1 ,

 

I tried the same but still it is not working.

AK79_0-1687186114837.png

 

My mistake , Styles only work on list views.
Have you looked at the client script that runs on Incidents "Highlight VIP Caller"?

Based on Incident client script i have modified my client script but it was not working. Dont know the reason ??