function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to get parent record type name from child object


I want to retrive in SOQL account record type from child object opportunity.

how can i write the query ?
Jerome RussJerome Russ
Select Id, Name, Account.RecordType.Name from Opportunity will get it for you.
[SELECT Id, Parent.RecordType.DeveloperName FROM Child]

User-added image

I have done as per your suggestion, but again i am not able to see their record type names. Here showing as[object object].
I want to see thier record type names.
Please help me on this.
if you query on the query editor it will display the [object, object] because it is parent

you can debug the recordType Name like this
for(Child obj: SELECT Id, Parent.RecordType.DeveloperName FROM Child)

run this code in developer console execute anonymous and check debug logs 
Pritam ShekhawatPritam Shekhawat
Try this 
select Account.RecordType.Name,(select id, Name from Opportunities )  from Account
Jerome RussJerome Russ
You can also use Workbench Query Editor to get around this Dev Console limitation.
Jerome Russ, I guess we can't query relationship field in workbench 
Jerome RussJerome Russ
It is an option. Go to the workbench setting and in the Query & Search option click on the check box "Allows SOQL Parent Relationship Queries"  and click on apply setting.
Jerome Russ.. Ahhh thanks for info. I was not aware of that Thanks.