Tuesday, June 19, 2018

How To Check Active Users in Role, Public Group and Queue Using SOQL query.

if you want to Find Number Of Active Users In a Role use the Below simple SOQL query.

Active Users in Role:
SELECT Id, Name, Email, isActive, Profile.Name, UserRole.Name, UserType FROM User WHERE UserRole.Name = '<Role Name>' AND isActive = true 
OR 
SELECT Count(Id) FROM User WHERE UserRole.Name = '<Role Name>' AND isActive = true 
find below screenshot for more information.



Active Users In Public Group:
SELECT Id, Name, Email, isActive, Profile.Name, UserRole.Name, UserType FROM User WHERE Id IN (SELECT UserorGroupId FROM GroupMember WHERE Group.Name = '<group Name>') AND isActive = true 
OR
SELECT Count(Id) FROM User WHERE Id IN (SELECT UserorGroupId FROM GroupMember WHERE Group.Name = '<Group Name>') AND isActive = true

find below screenshot for more information


Active Users In Queue:
SELECT Id, Name, Email, isActive, Profile.Name, UserRole.Name, UserType FROM User WHERE Id IN (SELECT UserOrGroupId FROM GroupMember WHERE Group.Type= 'Queue' AND Group.Name = ' <queue Name>') AND isActive = true
OR
SELECT Count(Id) FROM User Where Id IN (SELECT UserOrGroupId FROM GroupMember Where Group.Type= 'Queue' AND Group.Name = '<queue Name>') AND isActive = true

find below screenshot for more information



No comments:

Post a Comment