Set priority of Incident based on Caller field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 11:14 PM
Hello Developers,
I got a query, to set the priority of incident to P1-High, when the Caller selected is VIP?
Kindly help me achieve the solution.
Thanks in advance,
Lal Valecha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 11:19 PM
Create an on change client script on incident table on change of caller field.
var user = g_form.getReference('caller_id',func);
function func(user)
{
if(user.vip==true)
{
g_form.setValue('impact',1);
g_form.setValue('urgency',1);
}
}
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 11:24 PM - edited 12-11-2022 11:35 PM
Hello @Lal Valecha1 ,
This is the best practice to bring server side data on client, GlideAjax approach is best practice compared with getReference.
Please create onChange client script and use below code, the onchange client script should run based on caller change
var ga = new GlideAjax('HelloWorld'); // HelloWorld is the script include class ga.addParam('sysparm_name','helloWorld'); // helloWorld is the script include method ga.addParam('sysparm_user_name',newValue); // Set parameter sysparm_user_name to loggedinUser ga.getXML(HelloWorldParse); /* Call HelloWorld.helloWorld() with the parameter sysparm_user_name set to 'caller' and use the callback function HelloWorldParse() to return the result when ready */ // the callback function for returning the result from the server-side code function HelloWorldParse(response) { var answer = response.responseXML.documentElement.getAttribute("answer"); if(answer){
g_form.setValue('imapct',1);
g_form.setValue('urgency',1);
} }
and Create a client callable script include as below
// HelloWorld script include
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
helloWorld: function() {
var userName = this.getParameter("sysparm_user_name");
var grUser = new GlideRecord('sys_user');
grUser.get("sys_id", userName);
return grUser.vip;
},
type: 'GetUserInfo'
});
Learn more about GlideAjax by accessing below URL.
https://developer.servicenow.com/print_page.do?release=quebec&category=null&identifier=c_GlideAjaxAP...
Please mark this as helpful if you find this helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 11:24 PM
Please try like below:
//onchange CS on caller field
function onChange(control, oldValue, newValue, isLoading) {
var callerid = g_form.getReference('caller_id', getDetails);
function getDetails(callerid) { //callback function
if (callerid.vip == "true") {
g_form.setValue('urgency', "1");
g_form.setValue('impact', "1");
}
}
}
(not tested)
Murthy