Highlight VIP caller on incident form

Adarsh kumar si
Tera Contributor

There is OOB client script "Highlight VIP Caller " , to highlight the VIP caller. Is there any other way to achieve this functionality without the use of DOM Manipulation? 



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

Sandeep Rajput
Tera Patron
Tera Patron

@Adarsh kumar si If the OOTB script itself is using DOM manipulation then it must be the only way to highlight the VIP users. Had there been any other way folks at ServiceNow might have already implemented it by now. 

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Adarsh kumar si 

Nope

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

Amit Verma
Kilo Patron
Kilo Patron

Hi @Adarsh kumar si 

 

I don't think we have any other alternative to this OOB Client Script. As a workaround, I could think of displaying a field message below the caller field highlighting that the caller is VIP user as shown below:

 

AmitVerma_0-1736218899360.png

 

Thanks and Regards

Amit Verma


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

View solution in original post

11 REPLIES 11

Runjay Patel
Giga Sage

Hi @Adarsh kumar si ,

 

You can do something like below.

 

g_form.addDecoration('caller_id', 'icon-star', 'VIP User', 'color-green');

 

To get the VIP user in client script you need to call script include and return true and false.

Check this blog for calling script include from client script to get the vip user.

https://servicenowwithrunjay.com/glideajax-in-servicenow/

RunjayPatel_0-1736225342205.png

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...

Hi @Adarsh kumar si ,

 

Not sure which approach you had taken but I believe I also provided you the correct approach.

 

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.