function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc  novicesfdc novice 

How to Query the permission sets assigned to the Logged in User ?

Hi,

I need to query the Permission Sets assigned to the logged in User.I have written the following query,

List<PermissionSetAssignment> pset = [SELECT Id,Assignee.Name,PermissionSet.Name, PermissionSet.Label 
                                                     FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() ];

Can anyone confirm whether this is correct or do we need query in a differemt way..

Thanks.
 
Suresh31sSuresh31s
Looks Good. Do you see any error while running it? 
select PermissionSet.Name from PermissionSetAssignment where Assignee.Id = :userId order by PermissionSet.Name