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

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. 

@Adarsh kumar si I provided the same answer as accepted solution. Shouldn't my response be an accepted solution too?

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Adarsh kumar si 

 

Where do you want to show these highlights? In list view or in form?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Juhi Poddar
Kilo Patron

Hello @Adarsh kumar si 

I would not recommend modifying the OOTB script, as it may impact functionality in other areas of the platform. However, if you need to adjust the position of the VIP image, you can focus on the document.documentElement.getAttribute('data-doctype') == 'true' line, which determines the image's position.

If you are certain about the desired position, you can comment out that line and directly set bgPosition = "5% 45%"; (or any other value) to meet your requirements. Proceed cautiously, keeping in mind potential impacts on other functionalities.

Attaching screenshot for better understanding: 

JuhiPoddar_0-1736179852033.png

JuhiPoddar_1-1736179885287.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar