0

I'm a newbie at sales-force apex coding. I have 3 custom objects, Location(Parent) -> Group(child) - > Meeting(grand child). All are related to each other through Master detail relationships. I am trying to get 2 field values from the earliest Meeting Record that belongs to the Location.

So far I managed to get the get 2 field values from the earliest Meeting Record that belongs to the Business Object.

public List<Meeting__c> MeetingsList2 = [SELECT Name,
GPS_Meeting_Location__Latitude__s, GPS_Meeting_Location__Longitude__s FROM    
Meeting__c WHERE Group__c =:id ORDER BY Meeting_Date__c ASC LIMIT 1];

I am trying to get the same information obtained from the above query but this time I want to get the earliest Meeting (grand child) Record that belongs to the Group records (child) belonging to the Location Record from the Location Object (Parent object getting grandchild record field values)

Any help appreciated.

1

In SOQL only one level of parent-to-child relationship can be used in a query. But we can achieve it from opposite direction i.e. child-to-parent.

Like we have three predefined object :-

   Opportunity
   Quote - Child
   QuoteLineItems - Grand Child

Now you can write a query like this:-

SELECT Id, Quantity, Quote.Name, Quote.Opportunity.Name FROM QuoteLineItem where Quote.Opportunity.Id = xyz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.