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

@Juhi Poddar 

This question is not about position of the icon.

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

@Ankur Bawiskar 

Please correct me if I’m wrong, but as per my understanding, the DOM manipulation in this script is primarily used to determine the position of the VIP image. If there’s another reason for this manipulation that I may have missed, I would appreciate your insights.

 

Thank You 

Juhi Poddar

@Juhi Poddar 

The question is whether it can be achieved without using DOM

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

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

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.