Set priority critical if requested for is vip

Shweta91
Tera Contributor

How to set priority critical if caller is vip user.

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @Shweta91 ,

 

You can write onchange client script on caller, call script include to get vip true or false and if true then set the field value else clear the value.

client script code:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('UserUtils');
    ga.addParam('sysparm_name', 'checkVipUser');
    ga.addParam('sysparm_caller_sys_id', newValue);
    ga.getXML(ValidateVipUser);
    function ValidateVipUser(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        
        if (answer=='true') {
            g_form.setValue('priority', 1);
            g_form.setValue('urgency', 1);
            g_form.setValue('impact', 1);
        } else {
            g_form.clearValue('priority');
            g_form.clearValue('urgency');
            g_form.clearValue('impact');
        }
    }
}

 

Script include code:

var UserUtils = Class.create();
UserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    checkVipUser: function() {
        var caller = this.getParameter('sysparm_caller_sys_id');
        var gr = new GlideRecord('sys_user');
        gr.get(caller);
        return gr.vip;
    },
    type: 'UserUtils'
});

 

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

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

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

 

Hi @Runjay Patel ,

 

Thank you very much for your response, i will try your solution.