VIP Alert PopUp in SOW.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 01:55 PM
New sys admin to SNOW and looking for some assistance with a script to fire a VIP alert popup in agent workspace. This script I created is failing on the script include. Error states the title value is null. It is not, there is data there. Any assistance is appreciated. Thanks.
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Get the affected user's sys_id
var userSysId = newValue;
// Call the GlideAjax script
var ga = new GlideAjax('UserTitleChecker');
ga.addParam('sys_id', userSysId);
ga.getXMLAnswer(function(response) {
var userTitle = response.responseXML.documentElement.getAttribute('answer');
alert(userTitle);
// Check if the title contains 'president', 'svp', or 'evp'
if (userTitle && (userTitle.toLowerCase().includes('president') ||
userTitle.toLowerCase().includes('svp') ||
userTitle.toLowerCase().includes('evp'))) {
// Display the alert message
alert('Alert VIP');
}
});
}
Script Include:
var UserTitleChecker = Class.create();
UserTitleChecker.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserTitle: function() {
var userSysId = this.getParameter('sys_id');
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
return userGR.getValue('title');
}
return '';
}
});
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 03:33 PM
The GlideAjax block is missing the function name:
ga.addParam('sysparm_name', 'getUserTitle');
ga.addParam('sysparm_sys_id', userSysId);
Rewrote the script here:
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Get the affected user's sys_id
var userSysId = newValue;
// Call the GlideAjax script
var ga = new GlideAjax('UserTitleChecker');
ga.addParam('sysparm_name', 'getUserTitle');
ga.addParam('sysparm_sys_id', userSysId);
ga.getXMLAnswer(function(response) {
var userTitle = response.responseXML.documentElement.getAttribute('answer');
alert(userTitle);
// Check if the title contains 'president', 'svp', or 'evp'
if (userTitle && (userTitle.toLowerCase().includes('president') ||
userTitle.toLowerCase().includes('svp') ||
userTitle.toLowerCase().includes('evp'))) {
// Display the alert message
alert('Alert VIP');
}
});
}
Script Include:
var UserTitleChecker = Class.create();
UserTitleChecker.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserTitle: function() {
var userTitle = '';
var userSysId = this.getParameter('sysparm_sys_id');
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
userTitle = userGR.getValue('title');
}
return userTitle;
}
});