Query all roles, those assigned and not assigned #inSalesforce

Query all roles that are not assigned

SELECT Id, Name FROM UserRole WHERE Id NOT IN (SELECT UserRoleId FROM User WHERE UserRoleId !='')


Query all roles that are assigned

SELECT Id, Name FROM UserRole WHERE Id IN (SELECT UserRoleId FROM User WHERE UserRoleId !='')


Query all roles assigned or not assigned:

SELECT Id, Name FROM UserRole


Comments