Highlight a VIP using a label in incident form

Atheher Fathima
Mega Guru

Hi All,

 

I have a requirement to show up a label "VIP User" whenever the caller is a VIP. Also the name in the field should be highlighted in red colour in all states of an incident. Please advise on how to achieve this. We currently have a image show up however that isnt working well and we have got the requirement to display a label instead.

 

Please advise

Thank you!

4 REPLIES 4

Pratik Malviya
Tera Guru

Hi @Atheher Fathima ,

 

There is an OOTB client script on Incident table, You can use it for your requirement.

Client script name : "Highlight VIP Caller".

 

If its not there then you can write a client script of type onChange for field "caller".

and in script section paste below code.

 

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

function vipCallerCallback(caller) {
	var callerLabel = $('label.incident.caller_id').down('label');
	var callerField = $('sys_display.incident.caller_id');
	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: ""});
	}
}

 

Please mark helpful, if it helps you.

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks,
Pratik Malviya

hi @Pratik Malviya 

Yes we do have this client script, however once we submit the incident, the field changes to normal, we would like to retain the red highlight on the incident irrespective of the state it is in post submit as well. how do we achieve this?

 

Hi,

Since, you confirm you already have client script can you check if it is applicable under certain conditions. I believe you might have to play around with the existing script to make it work.

Namrata Ghorpad
Mega Sage
Mega Sage

Hello,

Configure style of Caller field and in the style field add the below code

background-image: url('images/icons/vip.gif');
background-repeat: no-repeat;
background-position: 98% 5px;
padding-right: 30px;

 

Regards,

Namrata