- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 02:10 AM
Hi
How would i Show Alert message on creating an incident record it should display the caller's location. By using g_scratchpad in BusinessRule and client script..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 03:43 AM
@Rajkumar Bommal - ah apologies, it was the caller's location not the current user.😅
If so, you can update the BR to
(function executeRule(current, previous /*null when async*/ ) {
var userGr = new GlideRecord("sys_user");
userGr.get(current.getValue('caller_id'));
g_scratchpad.currentLocation = userGr.getDisplayValue('location');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 03:37 AM
I updated my Profile location i.e., in system admin now its showing sys admin location only
Not the location of the caller that i have selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 03:43 AM
@Rajkumar Bommal - ah apologies, it was the caller's location not the current user.😅
If so, you can update the BR to
(function executeRule(current, previous /*null when async*/ ) {
var userGr = new GlideRecord("sys_user");
userGr.get(current.getValue('caller_id'));
g_scratchpad.currentLocation = userGr.getDisplayValue('location');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 03:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 03:42 AM
Display BR:
(function executeRule(current, previous /*null when async*/) {
// Fetch the caller's location
var caller = current.getValue('caller_id');
if (caller) {
var location = caller.location.getDisplayValue();
gs.info("Caller's Location: " + location);
// Store the caller's location in g_scratchpad
current.u_callers_location = location; // Store in a field
gs.scratchpad.caller_location = location; // Store in g_scratchpad
}
})(current, previous);
Client Script:
(function() {
var callerLocation = g_scratchpad.caller_location;
if (callerLocation) {
alert("Caller's Location: " + callerLocation);
}
})();
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks