Make urgency to priority when the caller is a VIP

Community Alums
Not applicable

Hi,

I am writing a script where I can set the Urgency of an incident to High when the caller is a VIP.

 

GlideAJAX

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

	var call = g_form.getValue("caller_id");
	g_form.addInfoMessage("caller is " + call);
	var ga = new GlideAjax("VIP_Set_Urgency_Class");
	ga.addParam("sysparm_name", "VIP_Set_Urgency_Function");
	ga.addParam("sysparm_Caller", call);
	ga.getXML(callBackFunction);
	function callBackFunction(response){
		var answer = response.responseXML.documentElement.getAttribute("answer");
		g_form.setValue("urgency", answer);
	}
   
}

 

GlideAJAX.jpg

 

Script Include

var VIP_Set_Urgency_Class = Class.create();
VIP_Set_Urgency_Class.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    VIP_Set_Urgency_Function: function() {
        var param = this.getParameter("sysparm_Caller");
        var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", param);
        gr.query();
        if (gr.next()) {
			if(gr.vip == true){
				
			}

        }
    },

    type: 'VIP_Set_Urgency_Class'
});

 

ScriptInclude.jpg

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Sai Shravan
Mega Sage

Hi @Community Alums ,

Here are a few modifications you can make to ensure the script works as intended

GlideAJAX:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var call = g_form.getValue("caller_id");
    g_form.addInfoMessage("Caller is " + call);
    var ga = new GlideAjax("VIP_Set_Urgency_Class");
    ga.addParam("sysparm_name", "VIP_Set_Urgency_Function");
    ga.addParam("sysparm_Caller", call);
    ga.getXML(callBackFunction);

    function callBackFunction(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer) {
            g_form.setValue("urgency", answer);
        }
    }
}

 

Script Include

var VIP_Set_Urgency_Class = Class.create();
VIP_Set_Urgency_Class.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    VIP_Set_Urgency_Function: function() {
        var param = this.getParameter("sysparm_Caller");
        var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", param);
        gr.query();
        if (gr.next()) {
            if (gr.vip == true) {
                return "1"; // Return "1" for High urgency
            }
        }
        return ""; // Return empty string if not a VIP
    },
    type: 'VIP_Set_Urgency_Class'
});

 

In the VIP_Set_Urgency_Function of the script include, I've added the return "1"; statement to indicate High urgency if the caller is a VIP. In the callBackFunction of the GlideAJAX script, I've added a check for the answer before setting the urgency field.

 

Regards,

Shravan

Please mark this as helpful and correct answer, if this helps you

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you

View solution in original post

2 REPLIES 2

Sai Shravan
Mega Sage

Hi @Community Alums ,

Here are a few modifications you can make to ensure the script works as intended

GlideAJAX:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var call = g_form.getValue("caller_id");
    g_form.addInfoMessage("Caller is " + call);
    var ga = new GlideAjax("VIP_Set_Urgency_Class");
    ga.addParam("sysparm_name", "VIP_Set_Urgency_Function");
    ga.addParam("sysparm_Caller", call);
    ga.getXML(callBackFunction);

    function callBackFunction(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer) {
            g_form.setValue("urgency", answer);
        }
    }
}

 

Script Include

var VIP_Set_Urgency_Class = Class.create();
VIP_Set_Urgency_Class.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    VIP_Set_Urgency_Function: function() {
        var param = this.getParameter("sysparm_Caller");
        var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", param);
        gr.query();
        if (gr.next()) {
            if (gr.vip == true) {
                return "1"; // Return "1" for High urgency
            }
        }
        return ""; // Return empty string if not a VIP
    },
    type: 'VIP_Set_Urgency_Class'
});

 

In the VIP_Set_Urgency_Function of the script include, I've added the return "1"; statement to indicate High urgency if the caller is a VIP. In the callBackFunction of the GlideAJAX script, I've added a check for the answer before setting the urgency field.

 

Regards,

Shravan

Please mark this as helpful and correct answer, if this helps you

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you

Hi @Community Alums ,

Can you please mark as correct answer if it solved your issue.

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you