How to restrict the group membership add / remove

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 03:53 AM
Hi,
I would like to implement the below scenario.
Only User A and B should be able to Add / remove the group membership for the Group name starts with "ABC" .
Other users should not modify the group membership.
Please suggest how to implement this without modifying any OOB ACL .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 04:06 AM
Hi @Community Alums ,
You can achieve this by and Advance business rule on table "sys_user_grmember".
Choose Insert and Delete option, after that in script part you can restrict by adding script.
Write an If block -> Check if group starts with "XYZ" if yes -> Check for user logged in is A or B. if yes then Continue else abort.
Thanks and Regards,
Rahul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 06:45 AM
@Community Alums You can use the following business rule to check if the user can edit the group members from the groups starting with ABC.
Here is the script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var validUserArry = ['<sys_id of user A>','<sys_id of user B>'];
if(validUserArry.indexOf(gs.getUserID())==-1){
current.setAbortAction(true);
gs.addErrorMessage('Only User A or B can Add/Update/Delete members from this group');
}
})(current, previous);
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:53 AM
Thank you very much for the response.
I tried the before BR and it works when i delete the group member it is throwing error.
but when i try to add a member using edit option it is showing below message and the below error message not showing .
"Only User A or B can Add/Update/Delete members from this group"
the user also not getting added but error message is not showing. please guide me, is there any way to show an error message for adding user also

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 08:45 AM
@Community Alums Update the BR script as follows and check it it fixes the issue.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var validUserArry = ['<sys_id of user A>','<sys_id of user B>'];
if(validUserArry.indexOf(gs.getUserID())==-1){
gs.addErrorMessage('Only User A or B can Add/Update/Delete members from this group');
current.setAbortAction(true);
}
})(current, previous);