Here is my controller. I want to expand the array so that the fields are accessible in my vfp. When I try referencing any fields from the inner query in my vfp I receive "Error evaluating dynamic reference. I want to return a list of all fields with no array (OG__c,OOC__c,U__c,UD__c,VD__c).

public with sharing class OController {
    public String OId {get;set;}
    public List<OG__c> ListOG{get;set;}
    public OController() {
       OId = ' ';
       Id i= Id.valueOf(OId);
        ListOG = new List<OG__c>();
        ListOG = [SELECT
        (SELECT U__c, UD__c, VD__c from OG__r WHERE PO__c = :i)
    FROM OG__c
        WHERE Id IN (
            SELECT OG__c
            from O__c
            WHERE PO__c = :i
        ORDER BY OG_Seq__c ASC, O_Seq__c];

1 Answer 1


To access the child records from the parent records, you need to use an array. This can be with apex:repeat, apex:dataTable, etc. If you don't want to do this, start your SOQL from the child object:

SELECT U__c, UD__c, VD__c, OG__r.OG__c, OG__r.OOG__c from OG__c WHERE PO__c = :i

My apologies if there's any mistakes with the field names, but it's rather hard to read your sample code. Just know that if you query from the child object, you'll be able to get the parent data as well, as a linear array.

You must log in to answer this question.

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