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.

  • Possible duplicate of Query on permission sets held by a user – Rohit Patil Oct 13 '15 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 – ajay bagdad Oct 13 '15 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. – ajay bagdad Oct 13 '15 at 7:09
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.

|improve this answer|||||
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
|improve this answer|||||
  • Thanks very much .Query is Working as expected..Kudos to you – ajay bagdad Oct 13 '15 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). – ajay bagdad Oct 14 '15 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 Oct 14 '15 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.