Icon styles beside fields

Vedavalli
Kilo Sage

Hi 
BESIDE CALLER FIELD vip icon is coming so i wanted show another icon like occ if called location starts with SH . If caller is vip then vip icon if caller location name starts with occ then occ icon is it possible?if yes how we can do

7 REPLIES 7

@Vedavalli usually the icons can be stored at UI System > Images, but the VIP.gif is not there...

 

I googled and found this:

GlideFather_0-1761906323104.png

https://yourinstance.service-now.com/image_picker.do

 

But you can upload your picture to the Images and link it..

———
/* If my response wasn’t a total disaster ā†™ļø ⭐ drop a Kudos or Accept as Solution āœ… ā†˜ļø Cheers! */


ArpithaMenden
Tera Contributor

Hello @Vedavalli 

 

Yes, it is possible , there is already a OOB script showing the VIP badge for the callers. You can extend this exact script to add your OCC icon logic

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;

var callerLabel = $('label.incident.caller_id').down('label');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;

if (!newValue) {
callerLabel.setStyle({ backgroundImage: "" });
callerField.setStyle({ color: "" });
return;
}

// Get caller reference
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;

// Reset styles
callerLabel.setStyle({ backgroundImage: "", paddingLeft: '' });
callerField.setStyle({ color: "" });

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

// āœ… Check VIP condition
if (caller.vip == 'true') {
callerLabel.setStyle({
backgroundImage: "url(images/icons/vip.gif)",
backgroundRepeat: "no-repeat",
backgroundPosition: bgPosition,
paddingLeft: '30px'
});
callerField.setStyle({ color: "red" });
}

// āœ… Check OCC condition (if location starts with 'SH')
else if (caller.location && caller.location.display_value.startsWith('SH')) {
callerLabel.setStyle({
backgroundImage: "url(images/icons/building.gif)", // replace with your OCC icon path
backgroundRepeat: "no-repeat",
backgroundPosition: bgPosition,
paddingLeft: '30px'
});
callerField.setStyle({ color: "blue" }); // optional style for OCC users
}
}

 

 

Please mark this response as correct and helpful if it assisted you with your question.

 

Regards,

Arpitha M

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Vedavalli 

where you want this? native or workspace?

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