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
vikramkkvikramkk 

Parent Child relationship

Hi

 

I want to know whether the parent child relationship works the same way in case of an opportunity and a task as it works in case of an account and a contact. Because in the following query when I query fields of a task in sub query, nothing is  returned.

 

optylist = [select name,keycode__c,taskid__c,(select subject,status from Tasks) from Opportunity where name='Test'];

 

Please correct me where I am going wrong.

nandurinanduri

The SOQL stmt is absolutely correct, not sure in what exactly is ur scenario.

dkadordkador

This query will return all opportunities named 'Test', regardless of whether or not they have tasks.  So perhaps you're seeing a number of opportuntities that don't have tasks.  Does either the parent or child query result have a queryLocator, indicating that there are more records to iterate through?