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

Lom
Tera Contributor

Hello, configure your client script like this:

Lom_0-1687249668067.png

 

and use this 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: ""});
}
}

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: ""});
    }
}