Assignment groups hidden for all groups expect a particular group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 03:59 AM - edited 06-05-2024 04:00 AM
Hi All,
I have a requirement and it says :
Suppose there is
1) Group A
2) Group B
3) Group C, D, E...and so on
Whenever the user group Group B logs in and opens the incident form in the Assignment group Field Group B member should be able to see Group A.
For Groups C, D, E...and so on ...Group A should be hidden.
(No one should be able to assign incidents to Group A except Group B)
How to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 04:47 AM
Create a script include (something like this):
var GroupVisibility = Class.create();
GroupVisibility.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getVisibleGroups: function() {
var userGroups = gs.getUser().getMyGroups(); // Get the groups the user belongs to
var visibleGroups = [];
var groupSysIdB = 'sys_id_of_group_b'; // Replace with the actual sys_id of group 'b'
var groupSysIdA = 'sys_id_of_group_a'; // Replace with the actual sys_id of group 'a'
// Check if user is a member of group 'b'
if (userGroups.indexOf(groupSysIdB) !== -1) {
// Add group 'a' and all other groups
visibleGroups.push(groupSysIdA);
}
// Add all other groups except 'a'
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', '!=', groupSysIdA);
gr.query();
while (gr.next()) {
visibleGroups.push(gr.sys_id.toString());
}
return visibleGroups.join(',');
},
type: 'GroupVisibility'
});
and an advanced reference qualifier like this:
answer = 'sys_idIN' + new GroupVisibility().getVisibleGroups();
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:29 AM
Hi @Mark Manders ,
Also could you please detail how to call script include in the business rule?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:31 AM
What business rule? You call it in an advanced reference qualifier on the field.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:32 AM