Skip to content

Instantly share code, notes, and snippets.

@techb
Created March 16, 2020 19:44
Show Gist options
  • Save techb/a5cef22d2dc54d301a93338115844773 to your computer and use it in GitHub Desktop.
Save techb/a5cef22d2dc54d301a93338115844773 to your computer and use it in GitHub Desktop.
Email Addresses by Permission Set
// 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