Salesforce: check if user has assigned permission set

Code to check if user has assigned permission set

1
2
3
4
5
6
7
8
static public Boolean checkIfUserHasAssignedPermissionSet(String userName, String permissionSetName) {
    List<PermissionSetAssignment> psas = [ select Id from PermissionSetAssignment where PermissionSetId IN ( select Id from PermissionSet where Name = :permissionSetName) and AssigneeId IN (select Id from User where UserName = :userName ) ];
    return psas.size() > 0;
}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *