REGION FIELD IN CLEINT SCRIPT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 12:10 AM
Can somebody help want wrong i am doing in the below on load script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 12:59 AM
Hi , I have tried using glideajax
can you please help me now what is wrong
var GetUserRegion = Class.create();
GetUserRegion.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// This function will fetch the user's region based on their location
getRegion: function() {
var userId = gs.getUserID(); // Get the current user's Sys ID
gs.info('Bhagat Singh: Fetching region for user with Sys ID: ' + userId); // Log user ID
var userGR = new GlideRecord('sys_user'); // Query the User table
if (userGR.get(userId)) {
// Dot-walk to get the region from the user's location
var userRegion = userGR.location.u_region; // Dot-walking to fetch the u_region field directly
// Log the fetched region
gs.info('Bhagat Singh: Region fetched from location: ' + userRegion); // Log the region
// Ensure we return a default value if no region is found
return userRegion || ''; // Return an empty string if no region is found
} else {
gs.error('Bhagat Singh: No user record found for Sys ID: ' + userId); // Log error if no user record is found
}
return ''; // Return an empty string if no region is found
}
});
var GetUserRegion = Class.create();
GetUserRegion.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRegion: function() {
var userId = gs.getUserID();
gs.info('Bhagat Singh: Fetching region for user with Sys ID: ' + userId); // Log user ID
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
var userRegion = userGR.location.u_region; // Dot-walking to fetch the u_region field directly
// Log the fetched region
gs.info('Bhagat Singh: Region fetched from location: ' + userRegion); // Log the region
// Ensure we return a default value if no region is found
return userRegion || ''; // Return an empty string if no region is found
} else {
gs.error('Bhagat Singh: No user record found for Sys ID: ' + userId); // Log error if no user record is found
}
return '';
}
});