When I run the query select id, RecordType.name from account , I am getting the records but when I run the similar below query, I am getting error.

select id, RecordType.name from opportunity

The error is

Didn't understand relationship 'RecordType' in field path. 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.

What might be causing the error since it is running fine for account and not for opportunity?

  • 3
    Do you have any record types defined on Opportunity?
    – Derek F
    Sep 16, 2021 at 13:37
  • Probably a safe bet to just post that as an answer.
    – Adrian Larson
    Sep 16, 2021 at 13:47

1 Answer 1


The RecordTypeId field is not added to an SObject until you define at least 1 record type for that SObject.

Having that (standard) relationship field is a prerequisite for being able to query RecordType.Name (i.e. you cannot traverse a relationship that doesn't exist).

  • It did not have any record type ! Thanks Derek. Sep 16, 2021 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .