How to restrict the group membership add / remove

Community Alums
Not applicable

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 .

7 REPLIES 7

Rahul Talreja
Mega Sage
Mega Sage

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.

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

Sandeep Rajput
Tera Patron
Tera Patron

@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.

Screenshot 2023-11-30 at 8.11.36 PM.pngScreenshot 2023-11-30 at 8.12.37 PM.pngScreenshot 2023-11-30 at 8.13.14 PM.png

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.

 

Community Alums
Not applicable

@Sandeep Rajput ,

 

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 

"Job to add or remove role(s) from user(s) of group has been queued"
 
 

@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);