Loading

Determine if a contact is a portal user

Publish Date: Oct 13, 2022
Description
How to determine if a Contact is a Portal User?
Resolution

Query the User table and use two 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 Apex Governor limits are not exceeded.
Knowledge Article Number

000386163

 
Loading
Salesforce Help | Article