I've an aura/Lightning Component Quick Action/button that checks to see if someone is part of the public group. If the user is part of the group they can run the quick action.

Originally there was only had a handful of users who were allowed access to run the action. Therefore I added the individuals to the public group. I was then able to check in the apex controller if the userId clicking the button matches, one of the UserOrGroupId's in the groupMember to check the user is part of the public group.

A request has now been made to open access up to more users via role and subordinates. Therefore I was going to add the role and subordinates to the public group.

How can I now check in in the apex controller if the user clicking the button/action is part of the public group when the only member of the group is now a role and subordinate?

Current code

    public static boolean rtwGroup() {
        boolean runCheck = false; 
        Group grp= [SELECT id, name, developerName FROM Group WHERE developerName = 'RTW_User' LIMIT 1];
        for(GroupMember gm : [SELECT Id, GroupId, UserOrGroupId 
                             FROM GroupMember 
                             WHERE GroupId =: grp.id]) {
                                  if(gm.UserOrGroupId == UserInfo.getUserId()) {
                                       runCheck = true;
       return runCheck;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.