- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 04:29 AM
Hi, I would like to know why the code doesn't work for me? What I need to do is as soon as I open an incident and put in the caller a client who is a VIP, then the priority automatically changes to 1. This is important as soon as I open before I save
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 08:10 AM - edited 11-20-2023 08:11 AM
Try this updated script, I tested this in my PDI, it is working fine.
Client Callable Script Include:
var CustomUserUtils = Class.create();
CustomUserUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkVIPFlag: function() {
var caller = this.getParameter("sysparm_caller");
var usrGr = new GlideRecord('sys_user');
if (usrGr.get("sys_id", caller)) {
return usrGr.getValue('vip') + '';
}
return '0';
},
type: 'CustomUserUtils'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getValue('caller_id');
var uGa = new GlideAjax('CustomUserUtils');
uGa.addParam('sysparm_name', 'checkVIPFlag');
uGa.addParam('sysparm_caller', caller);
uGa.getXMLAnswer(setPriority);
}
function setPriority(answer) {
if (answer == '1') {
g_form.setValue("impact", "1");
g_form.setValue("urgency", "1");
}
}
Result:
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 04:43 AM - edited 11-20-2023 04:47 AM
For getReference, you need to use callback function, as it goes back to Server and gets the data.
Try the below script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getReference('caller_id', popVIPPriority);
function popVIPPriority(caller) {
if (caller.vip == 'true') {
g_form.setValue("impact", "1");
g_form.setValue("urgency", "1");
}
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:36 AM
I can't in getReference due to system constraints, do you have another way of code to give me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 06:20 AM
@yardenKrispel Here is the code you should use if you do not wish to use getReference.
1. Script Include:Create a client callable script include as follows.
var GetUserInfo = Class.create();
GetUserInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getVIPStatus: function() {
var user_sys_id = this.getParameter("sysparm_user_sys_id");
var grUser = new GlideRecord('sys_user');
var vipStatus='';
if(grUser.get("sys_id", user_sys_id)){
vipStatus = grUser.getDisplayValue('vip');
}
return vipStatus;
},
type: 'GetUserInfo'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getValue('caller_id');
var ga = new GlideAjax('GetUserInfo'); // GetUserInfo is the script include name
ga.addParam('sysparm_name', 'getVIPStatus'); // getVIPStatus is the function in the script include that we're calling
ga.addParam('sysparm_user_sys_id', caller); // set user to Fred Luddy
/* Call GetUserInfo.managerName() with user set to Fred Luddy and use the callback function ManagerParse() to return the result when ready */
ga.getXMLAnswer(setVIPPriority);
}
// callback function for returning the result from the script include
function setVIPPriority(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.setValue("impact", "1");
g_form.setValue("urgency", "1");
}
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 06:26 AM
its not working the prioirty is not change