-2

How to get all permission set has a custom permission.

3
  • 3
    Can you rephrase the question? As written, it doesn't make much sense.
    – Derek F
    Commented Feb 24, 2023 at 0:50
  • 1
    I understand this. Why was it downthumbed? This helped me. Finding a Custom Permission in a permission set can be like a needle in a haystack. Commented Jan 25 at 21:03
  • that's why I haven't deleted this question, I know someone will benefit from it one day.
    – Ragul
    Commented Jan 31 at 19:51

1 Answer 1

3
SELECT ParentId FROM SetupEntityAccess
WHERE SetupEntityId IN (SELECT Id FROM CustomPermission WHERE DeveloperName ='yourCustomPermissionAPIName')

SELECT Name FROM PermissionSet where Id=:permissionSetIds

to get debug logs

Set<Id> permissionSetIds = new Set<Id>();
for (SetupEntityAccess access : 
    [SELECT ParentId FROM SetupEntityAccess WHERE SetupEntityId IN
               (SELECT Id FROM CustomPermission 
                  WHERE DeveloperName = 'yourCustomPermissionAPIName')]) {
    permissionSetIds.add(access.ParentId);
}
System.debug('--'+permissionSetIds);
for (PermissionSet ps : [SELECT Name FROM PermissionSet where Id=:permissionSetIds]) {
    system.debug(ps.Name);
}

Not the answer you're looking for? Browse other questions tagged .