You need to sign in to do that
Don't have an account?
VF with Parent Child relationship -- Error: Unknown property 'VisualforceArrayList.Opportunity'
I am trying to display the data returned by the below query but not successfull,
SELECT ID,Name, (SELECT Opportunity.amount FROM OpportunityContactRoles Order BY Opportunity.CloseDate DESC Limit 1 ) FROM Contact Where Lead_Source_Contact__c ='abc'
How can I display opportunity.amount using visualforce ?
<apex:pageBlockTable value="{!searchResults}" var="o" rendered="{!NOT(ISNULL(searchResults))}"> <apex:column headerValue="Name">
<apex:outputLink value="/{!o.Id}">{!o.Name}</apex:outputLink>
</apex:column>
<apex:column value="{!OpportunityContactRoles.Opportunity.amount}"/> I am getting error message Error: Unknown property 'VisualforceArrayList.Opportunity'
</apex:pageBlockTable>
TIA!!!!
Can you post more of your Apex code?
I think part of the issue is you are trying to use a list (OppContactRoles) as a single record. Given the relationships in your query, even a limited result quantity (1) will be treated as a list.
You might try creating a <apex:repeat> inside the column and looping over OpportunityContactRoles, then output Opportunity.amount
All Answers
Can you post more of your Apex code?
I think part of the issue is you are trying to use a list (OppContactRoles) as a single record. Given the relationships in your query, even a limited result quantity (1) will be treated as a list.
You might try creating a <apex:repeat> inside the column and looping over OpportunityContactRoles, then output Opportunity.amount
I felt the same and tired.... I also took help with Dynimaic VF binding and that did not work... may be i was doing something wrong.
Below is my code... Thanks for your help.
public PageReference search() {
if (searchResults== null) {
searchResults= new List<contact>(); // init the list if it is null
}
else {
searchResults.clear(); // clear out the current results if they exist
}
// use some dynamic soql to find the related opportunities by name AccountId = \''+a.Id+'\' , SELECT ID,Name, (SELECT Opportunity.amount FROM OpportunityContactRoles Order BY Opportunity.CloseDate DESC Limit 1 ) FROM Contact Where Lead_Source_Contact__c ='abc' ;
searchResults= Database.query(qry);
return null;
}