+ Start a Discussion
mustapha L 1mustapha L 1 

Does it exist a Method to get child object data ?

Hi all,

Im looking on way to make code easier to write (and read).
for now if i have to work on Contract , based on an Opportunity, i have to extract data from Opportunity (ie: opp.ContractID)
and then run a SQL query to get the Contract object linked to this Opportunity.
then i'm able to edit editable Contract fields.

is there any other way as there is a relation chip between those 2 objects ?

hope all this make sense..
thanks

Many thanks
 
Best Answer chosen by mustapha L 1
Prabhat Kumar12Prabhat Kumar12
Hi,

You can write something like this to get child data.
SELECT Id, Name, Industry, AnnualRevenue,
    ( SELECT Name, Email, BirthDate FROM Contacts )
    FROM Account
Note : - Contact is Child and Account is parent here.
Change object and field as per your requirment.


 

All Answers

Prabhat Kumar12Prabhat Kumar12
Hi,

You can write something like this to get child data.
SELECT Id, Name, Industry, AnnualRevenue,
    ( SELECT Name, Email, BirthDate FROM Contacts )
    FROM Account
Note : - Contact is Child and Account is parent here.
Change object and field as per your requirment.


 
This was selected as the best answer
mustapha L 1mustapha L 1
Many thanks that will be usefull. !!!