Display an icon or show a message at field level based on its value in Service Ops Workspace

JeremyHoffman
Tera Guru

Hello!

We are starting to configure the Service Operations Workspace to deploy and be used by our IT Department. On the Default view of an incident record, we have a VIP flag that appears for the Caller and or Opened for fields when the User's VIP flag = true. We also change the font color to Red, as you can barely see at the far right of the screenshot:

JeremyHoffman_0-1722598037526.png

We are currently doing this via 2 client scripts, one for each field. In the CS, the UI Type is set to Desktop.
Here is the 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: ""});
	}
}

We are hoping to accomplish this or something very similar in the Service Operations Workspace or Workspace UIB view. Any thoughts or suggestions on how to accomplish this?

 

Thank you in advance!

Jeremy

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You won't be able to do any DOM manipulation in a workspace, but the SOW team has added this functionality OOTB in the Xanadu version of the workspace. Workspaces also support adding field messages in a client script so that could be an option until you're able to upgrade.