0

I have to bring the values of a multiple child object of a Parent object in single query,

I tried the following method , however for query one child object as a first step it throws me the following error:

Error: "Didn't understand relationship 'OrderTraining__r' in FROM part of query call. 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."

the query is

newOrders = [select id,OrderNumber,(select Name__c from OrderTraining__r) from Order];

Please advise.

Thanks

  • @SimonGovaert i tried that as well, the error is similar "Didn't understand relationship 'OrderTraining' in FROM part of query call. 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." – Samuel Robert Dec 7 '16 at 10:13
  • 1
    it mostly ends with orderTrainings__r. 's' i feel. go to your child object open lookup/master field check 'Child Relationship Name' api name – Shravan Boddula Dec 7 '16 at 10:14
  • Seems like I was wrong, syntax is correct indeed, as per doc developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/… – Simon Govaert Dec 7 '16 at 10:20
1

Syntax is correct, check for the relation ship name OrderTraining__r.

Seems like OrderTraining is custom object, Navigate to lookup field on OrderTraining object to see the relationship name.


added more details:

enter image description here

  • If relationship name is Resources, I would use Resources__r in my subquery.
  • The relationship name is OrderId__c , when I replaced it it throws me the same error. The lookup field will have the Order number – Samuel Robert Dec 7 '16 at 10:16
  • added an example – Raul Dec 7 '16 at 10:21
  • I got that it was my mistake I missed OrderTrainings "s". Now I got it fixed. Thanks for your Help – Samuel Robert Dec 7 '16 at 10:22
0

enter image description here

Put Child relationship name and add __r to it. Example:

SELECT Id, (select Id from Taxi_Orders__r) FROM Account WHERE Name = 'Acme'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.