
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 04:38 AM
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);
}
}
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'
});
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 05:06 AM
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
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 05:06 AM
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
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 09:57 AM
Hi @Community Alums ,
Can you please mark as correct answer if it solved your issue.
Shravan
Please mark this as helpful and correct answer, if this helps you