You need to sign in to do that
Don't have an account?
Nishchal Vashisht 1
How to extract Account.Parent.Parent field value from SOQL Query
This is my query.
But instead of using get() if I directly use abc.Account.Parent.Parent.Name , I am getting result. But I don't know why my code fails in case of get(). In Actual scenario abc is of SObject type that's why I need to use get() here.
SOBject acc = [Select Id, Name, (Select Id, Account.Parent.Parent.Name, Name from Contacts__r) from Sales_Location__c where Id ='a005j000009xxxBAxU']; Contact abc =(Contact)(acc.getSobjects('Contacts__r')).get(0); System.debug(abc.get('Account.Parent.Parent.Name'));
But instead of using get() if I directly use abc.Account.Parent.Parent.Name , I am getting result. But I don't know why my code fails in case of get(). In Actual scenario abc is of SObject type that's why I need to use get() here.
You can get the related object fields like this
Thanks
Hope your query is answered below.
https://stackoverflow.com/questions/71908611/how-to-extract-parent-parent-field-value-from-soql-query
Thanks,