+ Start a Discussion

How can I query in Permissionsets, Groups and related objects of User?

I am trying this query  but getting syntax error:
SELECT Id, IsActive,(Select Id from GroupMembers),
                        (Select Id from PermissionSetAssignments) 
                                                  FROM User
                                          WHERE Isactive=true

What is the relationship name used for permissionsets and groupmembers?

Martijn SchwarzerMartijn Schwarzer
Hi Kabu,

GroupMember object has no lookup to the User object, and therefore cannot be queried from User object. You will need 2 queries:
List<User> users = [SELECT IsActive, Id, (SELECT Id FROM PermissionSetAssignments) FROM User WHERE isActive = true];

Set<Id> userIds = new Set<Id>();

for(User u : users){

List<GroupMember> = [SELECT GroupId, Id, SystemModstamp, UserOrGroupId FROM GroupMember WHERE UserOrGroupId IN :userIds];

Hope this helps!

Best regards,
Martijn Schwärzer