Created
March 16, 2020 19:44
-
-
Save techb/a5cef22d2dc54d301a93338115844773 to your computer and use it in GitHub Desktop.
Email Addresses by Permission Set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get list of email addresses by Permission Set | |
public static List<String> getEmailByPermSet(String permsetname){ | |
List<Id> just_ids = new List<Id>(); | |
List<PermissionSetAssignment> users = [ | |
SELECT AssigneeId | |
FROM PermissionSetAssignment | |
WHERE PermissionSet.Name = :permsetname | |
]; | |
for(PermissionSetAssignment uid: users){ | |
just_ids.add(uid.AssigneeId); | |
} | |
List<String> just_email = new List<String>(); | |
List<User> email_list = [SELECT Email FROM User WHERE User.Id IN :just_ids]; | |
for(User usr: email_list){ | |
just_email.add(usr.Email); | |
} | |
return just_email; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment