3

Select id, Account.Type from opportunity__c

I create a custom object opportunity and make relational on Account__c and account data type lookup but above query does not run and give below error

"Select id, Account.Type from opportunity__c ^ ERROR at Row:1:Column:12 Didn't understand relationship 'Account' 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."

Dilip Kr Singh
  • 1,418
  • 1
  • 18
  • 26

2 Answers2

3

Sounds like account is a custom field, in which case the field is called account__c, and the relationship is called account__r so your query should be select id, account__r.type from opportunity__c

superfell
  • 18,780
  • 4
  • 59
  • 81
  • God bless you!!!! I spent some 40 minutes on this crap trying to do it as `SELECT Field, (SELECT MyField FROM Relationship__r) FROM Primary` and apparently that is not even a thing :face_palm: – zaitsman Feb 21 '19 at 01:50
1

When you try to reach in a SOQL a field linked by a lookup or a Master-detail relationship you must put the suffix '__r' not the '__c'.

In your case, try with:

Select id, Account__r.Type from opportunity__c