function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinny Gebhart 10Vinny Gebhart 10 

Help with a SOQL query between custom object and standard object

Hi all,

Trying to query from a custom object, retrieve the owner (user), and return the related contact field on the user record.  

select ID, OwnerID, Name, owner.UserName, owner.IsActive, Owner.ContactID
from CustomObj1

The user type is Customer Community portal user
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below Query 

select ID, OwnerID, Name, CustomObj1.owner.UserName, CustomObj1owner.IsActive
from CustomObj1


Note: 

CustomObj1.Owner.ContactID Coz there is no relationship between your custom object and contact. 


Mark Best ANSWER if its works for you.. 

Thanks
karthik
 
Paradiso SolutionsParadiso Solutions
You cannot fetch the contact Id with your query as fetching the contactId based is based on the User who is currently logged in. Only Users who are enabled for Customer Portal will have a contact lookup on the user detail page.