Created
June 18, 2019 16:45
-
-
Save nithesh1992/41514821ce00d320a90ae914bc3df856 to your computer and use it in GitHub Desktop.
Find Users with Custom Permission in Apex
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
Set < Id > permissionSetIds = new Set < Id >(); | |
List < User > userList = new List < User >(); | |
for ( SetupEntityAccess access : [ SELECT ParentId FROM SetupEntityAccess | |
WHERE SetupEntityId IN ( SELECT Id | |
FROM CustomPermission | |
WHERE DeveloperName = 'Allow_Save_Offer_Owner_Edit' ) | |
]){ | |
permissionSetIds.add(access.ParentId); | |
} | |
System.debug(permissionSetIds); | |
userList = [ SELECT Username FROM User WHERE Id IN ( | |
SELECT AssigneeId FROM PermissionSetAssignment | |
WHERE PermissionSetId IN :permissionSetIds) ]; | |
System.debug(userList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment