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
Diane RoyerDiane Royer 

SOQL Query with Standard Object and Custom Object

I have another SOQL question.  I am now trying to set up a query that will join a Standard Object to a Custom Object.  There is a relationship between the two (on a lookup field on the custom object).  The child relationship name is Contact_Schedule.  I've rewritten the query several times, but nothing seems to work.  Below is the last thing I've tried.

SELECT TargetX_Eventsb__Contact__c, TargetX_Eventsb__event_end_date__c, TargetX_Eventsb__custom_field_1__c,
(SELECT Contact.Id FROM TargetX_Eventsb__ContactScheduleItem__c.Contact_Schedule__r)

    
FROM TargetX_Eventsb__ContactScheduleItem__c


WHERE TargetX_Eventsb__Contact__c= '0034M000020OgliQAC'

What am I doing wrong?
AbhishekAbhishek (Salesforce Developers) 
Try the suggestions as mentioned in the below discussions,

https://salesforce.stackexchange.com/questions/175682/custom-object-nested-query-on-standard-object

https://developer.salesforce.com/forums/?id=9060G000000I3d0QAC


It might help you.
Diane RoyerDiane Royer
I tried adding that code in the Execute Anonymous window, but every time I click on Execute, the window goes away and I can't see what the results were.  How do I get the Execute Anonymous window to show me the results of
for (ChildRelationship relation : SObjectType.Contact.getChildRelationships())
    if (relation.getChildSObject() == Contact.sObjectType)
        system.debug(relation.getRelationshipName());