- 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 06:55 AM
@yardenKrispel / @Sandeep Rajput
Change the client script to this one.
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(answer) {
if (answer == 'true') {
g_form.setValue("impact", "1");
g_form.setValue("urgency", "1");
}
}
And, Script Include to the one below.
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.getValue('vip') + '';
}
return vipStatus;
},
type: 'GetUserInfo'
});
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 07:04 AM
its not work. no change

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 07:41 AM
@yardenKrispel Could you please share the snapshot of your script include. Would like to check if Client callable checkbox on the script include is checked or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 06:09 AM
GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 04:51 AM
Try below code
function onLoad() {
var callerID = g_form.getReference('caller_id', VIPtrue);
function VIPtrue(callerID) {
if (callerID.vip) {
g_form.setValue("impact", "1");
g_form.setValue("urgency", "1");
}
}
}