You need to sign in to do that
Don't have an account?
Diane 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?
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?
https://salesforce.stackexchange.com/questions/175682/custom-object-nested-query-on-standard-object
https://developer.salesforce.com/forums/?id=9060G000000I3d0QAC
It might help you.
for (ChildRelationship relation : SObjectType.Contact.getChildRelationships())
if (relation.getChildSObject() == Contact.sObjectType)
system.debug(relation.getRelationshipName());