How to query Internal, Community/Portal and Community/Portal Users in Salesforce using SOQL?

How to query Internal, Community/Portal and Community/Portal Users in Salesforce using SOQL?

Internal Users:

SELECT Id, Name, IsActive, Profile.Name 
FROM User 
WHERE ProfileId IN ( 
SELECT Id 
FROM Profile 
WHERE UserType = 'Standard' 
)

Customer Community/Portal Users:

SELECT Id, Name, IsActive, Profile.Name 
FROM User 
WHERE ProfileId IN ( 
SELECT Id 
FROM Profile 
WHERE UserType = 'CSPLitePortal' )

Partner Community/Portal Users:

SELECT Id, Name, IsActive, Profile.Name 
FROM User 
WHERE ProfileId IN ( 
SELECT Id 
FROM Profile 
WHERE UserType = 'CSPLitePortal' )

Leave a Reply