+ Start a Discussion
Zhe Xu 2Zhe Xu 2 

grandparent and child relationship, is it difficult to implement in salesforce?

Hi,
I am a newbie to salesforce,my company hired some salesforce contractor to integrate salesforce with our internal database. I thought it is not difficult to do:
1. for each account, we add a custom field which is a List of object Tool.
2. For each object Tool, it has a list of object Group.
3. For each group, there are some custom fields.

So it is a grandparent -child relationship and I want to run a query for each account to return:
1. a list of custom tool objects,
2. in individual tool object, also return a list of group objects.

The contractor told me that it is rather difficult to implement in salesforce, is it right? I am a database and c# developer, at the moment, not really sure why this is difficult?

Can someone give me some idea?

Many Thanks 
 
SaranshSaransh
Hi Zhe,

Let me tell you in easy way. If we have a relationship like this A -> B -> C. So, for C, A is his grandparent. If you query on 'A' and want to pull out 'C' data. This is something not possible in one query because that would going to be something like this:

SELECT Id, (SELECT id, (SELECT id FROM C) FROM B) FROM A  //NOT VALID BECAUSE OF MORE THAN ONE LEVEL

If you going to fire this query in Salesforce it will going to give you an error : SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object

Let me know if I got you right. Then I can give you an idea of how to implement it in correct way.
Zhe Xu 2Zhe Xu 2
Oh, you are exactly right and makes lots of sense now. Just want to learn, what is the right way to implement it?