You need to sign in to do that
Don't have an account?

Need help with Navigating my soql query
Hi, I created a parent to child query that will relate son to father but I can not get the Name, Age__c from the Father__r. I am trying to return results in my visualforce page using outputfield. Could any one help.
son = [select Id, First_Name__c, Last_Name__c, Age__c,
(Select Id, Name, Age__c From Fathers__r)
from Son__c
where name=:ApexPages.currentPage().getParameters().get('id')];
<apex:outputField value="{}"/>
<apex:outputField value="{}"/>
Ok, so in your case, when you run the query, you get son and the related father objects.Right?
The exception that you are getting means, that the VF component is expecting a list of related records. So, basically, you have to loop through "{!son__c.fathers__r}" list in your VF page!
Something like-
<apex:repeat value="{!son__c.fathers__r}" var="temp">
{!temp}
</apex:repeat>
Cool_D
All Answers
Already answered on VF discussion board!
Cool_D
I keep on getting this error
Error: Unknown property 'VisualforceArrayList.Name'
This is what my class looks like:
This is what my Visualforce page looks like:
Try the below code-
public class sonExtension {
Son__c[] son;
public sonExtension(ApexPages.StandardController controller)
{
son = [select Id, First_Name__c, Last_Name__c, Age__c, Fathers__r.Id, Fathers__r.Name,Fathers__r.Age__c
from Son__c
where name=:ApexPages.currentPage().getParameters().get('id')];
}
}
I am assuming that Father__c is the Parent and Son__c is the child here!! Also, make sure that the relationship name is "Fathers__r" from son__c to father__c object.
Cool_D
Son__c object has 5 fields : Age__c (Number), Father(Lookup), First_Name__c(text), Last_Name__c(text), Name (Text).
Details within Father Lookup
Father__c object has Name, Age__c (Number), Son(Lookup)
Details within Son Lookup
Ok, so in your case, when you run the query, you get son and the related father objects.Right?
The exception that you are getting means, that the VF component is expecting a list of related records. So, basically, you have to loop through "{!son__c.fathers__r}" list in your VF page!
Something like-
<apex:repeat value="{!son__c.fathers__r}" var="temp">
{!temp}
</apex:repeat>
Cool_D
Man, Thank you soooooooo much. I was wondering with the repeat can you still do outputfield?
Thank you again for all the help.