You need to sign in to do that
Don't have an account?
Rahul22
SOQL Query on child related records
Hello Everyone,
I am new to salesforce development and need help on SOQL query.
We follow account hierarchy (Parent-Child relationship) and all opportunities which we create are associated with child accounts. Need help in querying all the opportunities of the child records which I want to show on parent record.
Regards,
Rahul
I am new to salesforce development and need help on SOQL query.
We follow account hierarchy (Parent-Child relationship) and all opportunities which we create are associated with child accounts. Need help in querying all the opportunities of the child records which I want to show on parent record.
Regards,
Rahul
In salesforce we have two different types of relationship query .
In salesforce Account is parent and Opportunity is child . There are two way parent to child and child to parent .
If parent to child then you need to write inner query .
If child to parent then you need to use relationship names in query .
Please check below link it will help .
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_using.htm#sforce_api_calls_soql_relationships_query_using
Let me know incase you have any issue .
Thanks
Manoj
Thanks for the info.
Actually, I want to query related objects of the child object on the parent object.
Here is the scenario:
Parent Account : A
Associated Child Accounts : Child A, Child B
Opportunities are associated with child A and B.
Now, I want to write a query which provides all the opportunities associated with child accounts (Child A&B) of parent account A.
My actual requirement is to display all the child accounts opportunities, tasks on the parent account related list using VF page.
Regards,
Rahul
May I request you please check the Salesforce documentation on "SOQL Relationship Queries" check below link.
- https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html (https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html )
Basic Examples of SOQL RELATIONSHIPS:Child > Parent (Standard Object) Child >Parent(Custom Object)
Parent >Child(Standard object) Parent >Child (Custom Object)
let us know if it helps.
Thanks
Rahul Kumar