How to Add VIP visual indicator for “Requested for” on RITM (similar to Incident Caller VIP)

nameisnani
Mega Sage

Hi Team,

I have a requirement to visually highlight VIP users on the Requested Item (RITM) form.


📌 Requirement

On the Requested Item [sc_req_item] form:

  • Field: Requested for (requested_for)
  • If the selected user has VIP = true (in sys_user.vip):
    • Show a VIP icon / decoration on the field, and optionally
    • Change the field text color (e.g., red) to make it stand out
  • If the user is not VIP:
    • No VIP indicator / normal display

This needs to work both when:

  1. The RITM is opened (onLoad)
  2. The Requested for field is changed by the user (onChange)


can anyone please help me - how to achieve this requriment .

thanks in advance 

11 REPLIES 11

Vaibhav Chouhan
Tera Guru

You can handle this the same way Incident handles the VIP Caller, just adjust it for RITM and the requested_for field.

Create an onChange Client Script on table sc_req_item for field requested_for. Also make sure “Isolate script” is unchecked, otherwise the DOM access and callback function won’t work properly.

Here’s the updated script:

function onChange(control, oldValue, newValue, isLoading) {

	var reqLabel = $('label.sc_req_item.requested_for');
	var reqField = $('sys_display.sc_req_item.requested_for');

	if (!reqLabel || !reqField)
		return;

	if (!newValue) {
		reqLabel.setStyle({backgroundImage: ""});
		reqField.setStyle({color: ""});
		return;
	}

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

function vipRequestedForCallback(user) {

	var reqLabel = $('label.sc_req_item.requested_for').down('label');
	var reqField = $('sys_display.sc_req_item.requested_for');

	if (!reqLabel || !reqField)
		return;

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

		var bgPosition = "95% 55%";
		if (document.documentElement.getAttribute('data-doctype') == 'true')
			bgPosition = "5% 45%";

		reqLabel.setStyle({
			backgroundImage: "url(images/icons/vip.gif)",
			backgroundRepeat: "no-repeat",
			backgroundPosition: bgPosition,
			paddingLeft: '30px'
		});

		reqField.setStyle({color: "red"});

	} else {
		reqLabel.setStyle({backgroundImage: ""});
		reqField.setStyle({color: ""});
	}
}

Since you also want it to work when the form opens, add an onLoad Client Script on sc_req_item as well, and again make sure Isolate script is unchecked:

function onLoad() {

	var requestedFor = g_form.getValue('requested_for');
	if (!requestedFor)
		return;

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

 

@Vaibhav Chouhan  Could you please provide for both Ritm and sctask also

nameisnani
Mega Sage

@Vaibhav Chouhan @Tanushree Maiti @Ankur Bawiskar 

I need for ritm and as well as sc_task also - please help me here 

@nameisnani 

I believe I already shared solution for your original question for RITM.

Simply check that OOTB and enhance for RITM table, simply change table as sc_req_item instead of incident and Do Insert and Stay.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

I have provided scripts for RITM table, you can use the exact same approach for sc_task as well. It’s the same logic, you just need to create the Client Scripts on the sc_task table instead of sc_req_item.

On sc_task, the Requested for field is also requested_for, so you basically duplicate the same onChange and onLoad Client Scripts, change the table to sc_task, and update the DOM selectors from sc_req_item to sc_task.

So for sc_task, your selectors would look like:

$('label.sc_task.requested_for')
$('sys_display.sc_task.requested_for')

Everything else in the script stays the same. Just don’t forget to uncheck “Isolate script” there as well.

That way, you’ll have VIP highlighting working on both RITM and Catalog Task forms.