+ Start a Discussion
Amit Jadhav 13Amit Jadhav 13 

How To Travel SOQL Upto 5 Level

I have created a 6 objects 
Test1
Test2
Test3
Test4
Test5
Test6

Test6(Lookup with Test5)
Test5(Lookup with Test4)
Test4(Lookup with Test3)
Test3(Lookup with Test2)
Test2(Lookup with Test1)

i want Test1 records in test 6 using soql

Please Help

Thanks,

Regards
Amit Jadhav
Best Answer chosen by Amit Jadhav 13
SAGAR LOKEGAONKARSAGAR LOKEGAONKAR
Hi Amit,

Actually we cannot write this child to parent for query for 6 level in Developer Console, we can only go upto 2 level in dp console. You have to Realfire Enterprise Software for this requirement.

You can use this link to download the sofware -  https://www.datasert.com/products/realfire/

Query - SELECT Name, Test5__r.Test4__r.Test3__r.Test2__r.Test1__r.Name FROM Test6__c

Thanks & Regards,
Sagar

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Amit,

Greetings to you!

You can use the below query:
SELECT Name, Test5__r.Test4__r.Test3__r.Test2__r.Test1__r.Name FROM Test6__c

Please refer to the below links which might help you further with the above requirement.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_limits.htm

https://www.sfdc99.com/2013/06/09/example-how-to-write-a-cross-object-soql-query/

https://www.sfdc99.com/2013/06/24/example-how-to-write-a-cross-object-soql-query-part-2/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Amit Jadhav 13Amit Jadhav 13
help
SAGAR LOKEGAONKARSAGAR LOKEGAONKAR
Hi Amit,

Actually we cannot write this child to parent for query for 6 level in Developer Console, we can only go upto 2 level in dp console. You have to Realfire Enterprise Software for this requirement.

You can use this link to download the sofware -  https://www.datasert.com/products/realfire/

Query - SELECT Name, Test5__r.Test4__r.Test3__r.Test2__r.Test1__r.Name FROM Test6__c

Thanks & Regards,
Sagar
This was selected as the best answer
Amit Jadhav 13Amit Jadhav 13
Thanks Sagar