+ Start a Discussion
Shruthi GM 4Shruthi GM 4 

What is this error?..Why does this error comes up?

System.QueryException: Didn't understand relationship 'Id' 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.
Ramssf70Ramssf70
Hi shruthi,
 You might have written the query in wrong way if you can share the query  i  will  try to help you
Amit Singh 1Amit Singh 1
Hi Shruthi,

This error comes when you are trying to fetch any fields of Child Object relationship may be Master/Lookup without inner query. If you want to fetch child object fields then use inner query. For example, the query is given below:
 
Select Id, NAme, (Select Id, Name From Vehicles__r) From Account
Hope this make sense :)

Thanks,
Amit
 
pkpnairpkpnair

Hi Shruthi,
This error is potentially because you have given a wrong Relationship Name name in your nested inner query in SOQL.

Solution: Open workbench. Goto ->Info-->Standard & Custom Objects-->Choose your parent object
It will display the folders which will have one named as "Child Relationship"" Open this folder and choose the Child object you are refereing in your inner query. Choose the field "relationshipName" from this list and use it in your SOQL.

This will solve this error.
-Prakash

 

Shruthi GM 4Shruthi GM 4
Hi All,

So if I have to fetch one of the fields from Opportunity object how do I write the inner query?
Like for Eg:- Select Id, NAme, (Select Id, Name From Vehicles__r) From Account
In place of Vehicles__r I need to add Opportunity object.How do I do that?
Please help.
Amit Singh 1Amit Singh 1
Hi Shruthi,

From which object you need to fetch the Opportunity Filed?

Let me know so that I could help you. Also, paste your SOQL query here.

Thanks,
Amit
Amit Singh 1Amit Singh 1
Shruthi, 

If you want to fetch Opportunity Fields from Account then use the below query.
 
Select Id, Name, (Select Id, Name From Opportunities) From Account

Hope this will do the trick.

If this helps make answer as best answer and keep community clean :)

Thanks,
Amit Singh.
Shruthi GM 4Shruthi GM 4
Even after adding the inner query am facing the same error!!!!
Amit Singh 1Amit Singh 1
Shruthi, will you paste your query here so that I could help you on this. I believe that you are doing something wrong in SOQL query.

Below are some points for making downward SOQL and upward SOQL queries.

If you want to Fetch records from parent to child then you should use Inner query as above.
Select Id, Name, (Select Id, Name From Opportunities) From Account
If you want to fetch Parent record field then use the SOQL query like below.
Select Id, Name, Account.Name From Opportunity
Also, check the API name of your object that you are using as parent Object.

Paste your query here and relationship between objects so that I could help :)

Thanks,
Amit Singh.
 
pkpnairpkpnair
Sruthi,
Can you paste your query here? I not totally sure what you are trying to select.
Prakash