If logged in user is member of current assignment group then populate the alert message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 11:45 AM
Hi All,
I need to populate the alert message when If logged in user is member of current assignment group.
For this I tried with the display business rule and client script,
Display business rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:40 PM - edited 08-13-2024 01:12 PM
Are you aiming to display an alert message when the logged-in user is an incident assignment group member? If so, try this approach.
Display Business Rule:
(function executeRule(current, previous /*null when async*/ ) {
if (current.assignment_group) {
var userIsMember = gs.getUser().isMemberOf(current.assignment_group.toString());
g_scratchpad.isGroupMember = userIsMember;
}
})(current, previous);
OnLoad Client Script :
function onLoad() {
if (g_scratchpad.isGroupMember) {
alert("You are a member of the assignment group for this incident.");
} else {
alert("You are not a member of the assignment group for this incident.");
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Thanks & Regards,
Priyanka Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 01:02 PM
Hi @vinuth v ,
Please try below script:
1. Create Script Include
Name : CheckmemberOf
Make Sure Client Callable is checked to true.
var CheckmemberOf = Class.create();
CheckmemberOf.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkGroupMember: function() {
var grp = this.getParameter('sysparm_grp');
return gs.getUser().isMemberOf(grp);
},
type: 'CheckmemberOf'
});
2. Use above script include from client side script.
function onLoad() {
var ga = new GlideAjax('CheckmemberOf');
ga.addParam('sysparm_name', 'checkGroupMember');
ga.addParam('sysparm_grp', 'use the sys_id of group here');
ga.getXML(checkGroup);
}
function checkGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
alert('Logged in User is part of group');
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Thanks &Regards,
Sumanth Meda