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

Community Alums
Not applicable

@Sandeep Rajput ,

 

I tried the updated script but still the error message is not showing .

can we hide the Edit option on group table , instead of error message ?

TamilselvanPar_0-1701364878005.png

 

 

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Community Alums ,
I trust you are doing great.
Here is an example of a script that could be used in either a Business Rule or a Scripted ACL. This script checks if the current user is User A or User B and if the group name starts with "ABC". If these conditions are met, the script allows the modification:

(function executeRule(current, previous /*null when async*/) {

    // Define the usernames or unique identifiers of User A and User B
    var allowedUsers = ['userA_username', 'userB_username']; 

    // Check if the current user is User A or User B
    var isAllowedUser = allowedUsers.indexOf(gs.getUserID()) > -1;

    // Check if the group name starts with "ABC"
    var isABCGroup = current.name.startsWith('ABC');

    // Allow modification only if the user is allowed and the group starts with ABC
    if (isAllowedUser && isABCGroup) {
        return true; // Allows the operation
    }

    // Optionally, add a message to inform unauthorized attempts
    gs.addErrorMessage('You do not have permission to modify this group.');

    return false; // Prevents the operation for other cases

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Community Alums
Not applicable

Hi,

 

I tried the updated script and still same results.

 

when i open the Groups table, it is showing Edit option visible .

Instead of showing error message How can we hide the edit option if the user is not A and B & Group is start with Test.

 

please suggest.