0

I am working with a 4 Level parent - child Relationship:

I have following custom objects Level1__c (Parent) Level2__c (Child) Level3__c (Grand Child) Level4__c (Great Grand child)

I am trying to pull records from Level2, Level3 & Level4, but I am getting this error

SOQL tried (Sample) :

SELECT Id,Name, (SELECT Id,Name FROM Level3s__r),(SELECT Id,Name from Level4s__r)
from Level2__c WHERE Id = 'a3438&Yfdfdgg'

Error:

INVALID_TYPE:
(SELECT Id,Name from Level4s__r)
^
ERROR at Row:2:Column:149
Didn't understand relationship 'Level4s__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

I am able to fetch Level2,Level3 or Level3,Level4 but all 3 levels I am not able to fetch. Can someone help me how to resolve this?

2
  • My error is different from the link Mar 30, 2021 at 14:22
  • Because there is no direct relationship between the parent and grandchild. As the answer says, you can only query one level down in the relationships -- for deeper levels, you must do separate queries. Mar 30, 2021 at 14:24

0

Browse other questions tagged .