You need to sign in to do that
Don't have an account?
Nurav1982
SOQL Quick Question
I have the following 3 custom objects
Parent
Child
GrandChild
GrandChild has a lookup relationship with Child.
Child has a MD relationship with Parent (Parent is Master)
Objective : I want to traverse from grandchild to parent.
select gc.name,c.name,p.name
from grandchild__c g, g.child__r c, c.parent__r p
I am getting sample output like below
Name child__r.Name child__r.parent__r.Name
"Test GC" "Test C" [object Object]
Can anyone tell me why am I getting "[object Object]" instead of the parent's name ???
Parent
Child
GrandChild
GrandChild has a lookup relationship with Child.
Child has a MD relationship with Parent (Parent is Master)
Objective : I want to traverse from grandchild to parent.
select gc.name,c.name,p.name
from grandchild__c g, g.child__r c, c.parent__r p
I am getting sample output like below
Name child__r.Name child__r.parent__r.Name
"Test GC" "Test C" [object Object]
Can anyone tell me why am I getting "[object Object]" instead of the parent's name ???
Intresting..... So do you look what is the body of this Object is
like you say that child__r.parent__r.Name return you [object Object] then this object must have some body like a wrapper
beacus as per my understnanding it must return you an string only
select gc.name,c.name,p.name
from grandchild__c gc,gc.child__r c,c.parent__r p
Hi Subramani,SRK,
Plz take a look at the screenshot and the query and let me know if you need anything.
In each specified relationship, only one level of parent-to-child relationship can be specified in a query. For example, if the FROM clause specifies Account, the SELECT clause can only specify the Contact or other objects at that level. It could not specify a child object of Contact.
I tried doing from grandchild to child to parent relationship also but still nothing..but i get [Object Object] only :(
select grandchild__c.id,grandchild__c.name,grandchild__c.child__r.name,grandchild__c.child__r.parent__r.column1__c
from grandchild__c
Also I agree that we have one level traversal when we move from parent to child though.
System.debug([select id,name,grandchild__c.child__r.name,grandchild__c.child__r.parent__r.name from grandchild__c]);
Output
15:50:46:072 USER_DEBUG [1]|DEBUG|(GrandChild__c:{Name=TEST lookup, Id=a0G9000000EOWQREA5, Child__c=a099000000NZeC5AAL})
Still no parent name
List<grandchild__c> TempLst = [select id,name,grandchild__c.child__r.name,grandchild__c.child__r.parent__r.name from grandchild__c];
System.debug('#@!#@#!@#!@$@#@#'+TempLst[0].child__r.name);
System.debug('#@!#@#!@#!@$@#@#'+TempLst[0].grandchild__c.child__r.parent__c);
System.debug('#@!#@#!@#!@$@#@#'+TempLst[0].grandchild__c.child__r.parent__r.name);