+ Start a Discussion
renuamirenuami 

help on parent child relationship queries

on Case Object i have a custom field case_assigned_to__c (LOOKUP) to user.

 

  FieldName is Case_Assigned_to

  API Name  is Case_Assigned_to__c

 Child Relationship Name is AssignedTo

 

When i query

 

 

(Select Id,Contact.Name,Subject,ClosedDate,Owner.Name,Case_Assigned_to__c.Name from case limit 10)

I am receving this error Didn't understand relationship 'Case_Assigned_to__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.

 
I also tried AssignedTo__r.Name

 

Please advise....How to grab the user name ?

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
arunkarunk

Hi,

 

Should be. 

Select Id,Contact.Name,Subject,ClosedDate,Owner.Name,Case_Assigned_to__r.Name from case limit 10 

I also use Eclipse to create complicated queries.

 

 

Regards,

Arun 

All Answers

aalbertaalbert

You could use the Force.com IDE and the Schema Explorer (open up the salesforce.schema icon in your Force.com IDE Project). Then expand out the Case object, and list out the child Relationships and select the desired fields from your "Case Assigned To" relationship. Then the SOQL is built for you automatically in the IDE to test out the query.

 

 

arunkarunk

Hi,

 

Should be. 

Select Id,Contact.Name,Subject,ClosedDate,Owner.Name,Case_Assigned_to__r.Name from case limit 10 

I also use Eclipse to create complicated queries.

 

 

Regards,

Arun 

This was selected as the best answer