You need to sign in to do that
Don't have an account?
SOQL subquery - object with relationships
Hi,
I have three custom objects: Asignados__c, Aspirante__c and Vacante__c. The Asignados__c object has a master detail relationship whith Aspirante__c and also with Vacante__c of this way:
Vacante__c <--- Asignados__c ---> Aspirante__c
I want to query the Asignados__c object to show the result in a table of a vf page of this way:
Vacante__c value 1 Aspirante__c value 1
Aspirante__c value 2
Aspirante__c value 3
Aspirante__c value 4
Vacante__c value 2 Aspirante__c value 1
Aspirante__c value 2
Aspirante__c value 3
Aspirante__c value 4
Vacante__c value 3 Aspirante__c value 1
Aspirante__c value 2
Aspirante__c value 3
Aspirante__c value 4
I have this query:
List<Asignados__c> arbolvacs = [Select Vacante__r.Name,(Select Name From Aspirante__r) From Asignados__c Order By Vacante__r.Name];
But I receive this error:
Error: Compile Error: Didn't understand relationship 'Aspirante__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. at line 16 column 37
I tried also with the Child Relationship Name: Vacantes_Aspirantes1 and Vacantes_Aspirantes1__r but I receive the same error.
Thanks for any help..
Did you try aspirantes__r? Failing that, if you look at the Aspirante__c field on the Asignados__c object, it will show you the child relationship name - you just need to add '__r' to that name.
Yes, I tried with Aspirantes__r and with the child relationship name with "__r" and without "__r" what is Vacantes_Aspirantes1 and Vacantes_Aspirantes1__r but don't work, I get the same error: Didn't understand relationship.
I don't know what is wrong.
Have you tried looking for the relationship via the force.com ide?
No. I don't know how do it. Do you mean the plugin that is installed on Eclipse?
Yes - if you are using that you can go to the schema explorer, open the parent object and look at its child relationships.
Failing that, if you open the child object definition in the salesforce setup screen, then click through on the field that has the lookup to the parent, you should see the child relationship detailed there.