im new to visualforce and i have this problem: I have a sObject with customField1__c, customField2__c, customField3__c.

In my main page (with a standard controller and an extension) i want to display a table in wich i want to see all the customField1__c, customField2__c, customField3__c that are related to my customField1__c.

I'm trying to use a aggregateResult because otherwise i have a lot of duplicates in customField__1, but i have this error:

"Invalid field customField__c for SObject AggregateResult Error is in expression '{!myQuery.customField1}' in component apex:outputText in page myQuery"

here is my main page:

        <tr> <th> My table title </th> </tr>
            <td> <b> Field1 </b> </td>
            <td> <b> Fiel2 </b> </td>
            <td> <b> Field3 </b> </td>

        <apex:repeat value="{!myQuery}" var="myQuery">
                <td>  <apex:outputText value="{!myQuery.CustomField1__c}"/> </td>
                <td> <apex:outputText value="{!myQuery.CustomField2__c}"/> </td>
                <td> <apex:outputText value="{!myQuery.CustomField3__c}"/> </td>

Then I have my page Extension:

public with sharing class MyPageExtension {

    public List<AggregateResult> indicatorNotes{get;set;}

    public MyPageExtension(ApexPages.StandardController ctrl) {   

        myQuery=[ SELECT customField1__c, customField2__c, customField3__c
        FROM customObject__c
               GROUP BY customField1__c, customField2__c, customField3__c

thanks in advance

1 Answer 1


AggregateResult objects are treated like sObject objects; you can't access any of the fields directly with the dot-notation, but instead you need to use the dynamic notation.

<td>  <apex:outputText value="{!myQuery['CustomField1__c']}"/> </td>

Also, you shouldn't name the var the same as the value; this can cause the compiler to also not do the right thing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .