Print this page

Determine if a contact is a portal user

Knowledge Article Number 000182146
Resolution

Query the User table and use 2 key filters

 
  • [SELECT Id,Name,Email FROM User WHERE Profile.Name = 'Customer Portal User' AND ContactId = '003xxxxxxxxxxxxxxx'
 

Query against multiple contacts 

 
  • List<Contact> lContacts = [SELECT Id FROM Contact];
  • List<User> lUsers = [SELECT Id,Contact.Id,Name,Email FROM User WHERE Profile.Name = 'Customer Portal User' AND ContactId IN :lCont];

NOTE: The first query on Contact will have to be limited so that you don't pass governor limits. To learn more, read our Developer Documentation about Governors and Limits.
 




promote demote