4

Requirement:I need to fetch a data with username with profileName and permission Sets assigned to users based on profile.

Here I have written a Query for fetching user. Below is the query

select  user.FirstName, user.profile.name FROM user where user.IsActive=true and  user.profile.name='Standard User'

Can anyone please modify the query so i will get all the users permission set assigned.

3
  • Possible duplicate of Query on permission sets held by a user Commented Oct 13, 2015 at 6:49
  • Thanks Rohit,But is this possible in a single query to find profile name and Permission sets assigned to User based on Profile Name Commented Oct 13, 2015 at 6:53
  • Please help me out here to solve this problem as this is very critical. Basically i need to fetch active users profiles and Permission sets(but its very difficult to query for each user ,So here i am trying to fetch by profile name ).I am getting user names based on profile ,but how i can get for each users permission sets. Commented Oct 13, 2015 at 7:09

2 Answers 2

2

Please let me know if this works for you : SELECT count() FROM PermissionSetAssignment p WHERE p.PermissionSet.IsOwnedByProfile = false AND p.Assignee.Profile.Name = 'System Administrator'

Please mark this as best answer if it resolves your query.

6

Try the SOQL code below :

SELECT p.Id, p.Assignee.Name, p.Assignee.Profile.Name, p.PermissionSet.Label
FROM PermissionSetAssignment p
WHERE p.PermissionSet.IsOwnedByProfile = false AND p.Assignee.Profile.Name = 'System Administrator'
ORDER BY p.AssigneeId, p.PermissionSetId
3
  • Thanks very much .Query is Working as expected..Kudos to you Commented Oct 13, 2015 at 7:14
  • HI Vipul, Is this possible to get count for each profile and for each permission set how many users are there (count). Commented Oct 14, 2015 at 6:29
  • Please let me know if this works for you : SELECT count() FROM PermissionSetAssignment p WHERE p.PermissionSet.IsOwnedByProfile = false AND p.Assignee.Profile.Name = 'System Administrator'
    – Vipul Goel
    Commented Oct 14, 2015 at 6:57

You must log in to answer this question.

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