Highlight VIP caller in client script

sivaiah
Kilo Contributor

Highlight VIP caller in client script

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there is already OOB script for this on incident table

What is required then?

find_real_file.png

regards
Ankur

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there is already OOB script for this on incident table

What is required then?

find_real_file.png

regards
Ankur

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

Shakeel Shaik
Giga Sage
Giga Sage

Hi @sivaiah 

you will also find this script on PDI Instance. as Ankur Sir mentioned.

 

Here is the script:

find_real_file.png

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"
        });
		
		if(oldValue == newValue)
		g_form.setMandatory('work_notes', false);   
	else
		g_form.setMandatory('work_notes', true); 
//         g_form.setValue('impact', 1);
//         g_form.setValue('urgency', 2);
//         g_form.setValue('priority', 2);

    } else {
        callerLabel.setStyle({
            backgroundImage: ""
        });
        callerField.setStyle({
            color: ""
        });


    }


}
Thanks,
Shakeel Shaik 🙂

I don't think there is any need to share the script as it will be available directly in the instance.

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

@sivaiah 

Did you mistakenly marked other response as correct?

The correct response was already shared by me as 1st response to your question

The response marked as correct is stating the same thing which I already mentioned.

Please mark my response as correct and helpful based on timely response

Regards
Ankur

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