- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 02:23 AM
Hi I have requirement to set the Description "Caller is VIP" if caller is VIP.
I am new to the platform.
I am not able to find mistakes in my code Can anyone help.
Client script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 12:03 AM
@Suraj Mahajan Please follow the below steps for your requirement,
1. Script Include:
var setDescCallerVIP = Class.create();
setDescCallerVIP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getcallerinfo: function() {
var clr = this.getParameter('sysparm_caller');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', clr);
gr.query();
while(gr.next()){
var vipStatus = gr.getValue('vip');
return vipStatus;
}
},
type: 'setDescCallerVIP'
});
2. Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var vr = new GlideAjax('setDescCallerVIP');
vr.addParam('sysparm_name', 'getcallerinfo');
vr.addParam('sysparm_caller', g_form.getValue('caller_id'));
vr.getXML(setdet);
function setdet(response) {
var vipStatus = response.responseXML.documentElement.getAttribute('answer');
alert(vipStatus);
if (vipStatus == true) {
g_form.clearValue('description');
g_form.setValue('description', 'This Caller Is VIP');
} else {
g_form.clearValue('description');
g_form.setValue('description', 'This Caller Is Not VIP');
}
}
}
Results :
If the caller is not VIP,
If the caller is VIP,
Note: Comment out the alert on the client script.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 12:03 AM
@Suraj Mahajan Please follow the below steps for your requirement,
1. Script Include:
var setDescCallerVIP = Class.create();
setDescCallerVIP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getcallerinfo: function() {
var clr = this.getParameter('sysparm_caller');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', clr);
gr.query();
while(gr.next()){
var vipStatus = gr.getValue('vip');
return vipStatus;
}
},
type: 'setDescCallerVIP'
});
2. Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var vr = new GlideAjax('setDescCallerVIP');
vr.addParam('sysparm_name', 'getcallerinfo');
vr.addParam('sysparm_caller', g_form.getValue('caller_id'));
vr.getXML(setdet);
function setdet(response) {
var vipStatus = response.responseXML.documentElement.getAttribute('answer');
alert(vipStatus);
if (vipStatus == true) {
g_form.clearValue('description');
g_form.setValue('description', 'This Caller Is VIP');
} else {
g_form.clearValue('description');
g_form.setValue('description', 'This Caller Is Not VIP');
}
}
}
Results :
If the caller is not VIP,
If the caller is VIP,
Note: Comment out the alert on the client script.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 04:36 AM
@Sujatha V M Thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 05:49 AM
@Suraj Mahajan Glad to help you on it! Kindly understand the logic and implementation so that you will be able to help others too 🙂
Happy Learning!
Sujatha V.M.