0

I have soql query which will have subquery to get the value of the child object values. However there is no error in the query but the values that suppose to display is displaying as null in VF page.

Query:

newOrders = [Select id, ...
                        (select id, Name__c,OEmail__c,Phone__c,OrderId__c from OrderTrainings__r) 
                     from Order where OrderNumber IN :splits]; 

Display page. enter image description here`

When I checked the query using query editor it shows me the returned value for the subquery as well.

Below is my VF page for the table:

 <apex:outputPanel rendered="{!order.Training_Required__c=='Yes' && order.Type_Of_Order__c=='New Client or Web Time Branch'|| order.Type_Of_Order__c== 'Redeploy' || order.Type_Of_Order__c== 'Reactivation'}" >                    
                <apex:pageBlockTable value="{!newOrders}" var="training" style="width:50%">                        
                    <apex:column headerValue="Name">
                        <apex:outputText value="{!OrderTrainings.Name__c}"/>
                    </apex:column>
                    <apex:column headerValue="Email">
                        <apex:outputText value="{!OrderTrainings.OEmail__c}"/>
                    </apex:column>
                    <apex:column headerValue="Phone"> 
                        <apex:outputText value="{!OrderTrainings.Phone__c}"/> 
                    </apex:column>
                </apex:pageBlockTable>
            </apex:outputPanel>

Please Advise.

2 Answers 2

2

If you are expecting only one order and want to print the details for the OrderTrainings use the below VF page snippet -

<apex:outputPanel rendered="{!order.Training_Required__c=='Yes' && order.Type_Of_Order__c=='New Client or Web Time Branch'|| order.Type_Of_Order__c== 'Redeploy' || order.Type_Of_Order__c== 'Reactivation'}" >                    
    <apex:pageBlockTable value="{!order.OrderTrainings__r}" var="OrderTrainings" style="width:50%">                        
        <apex:column headerValue="Name">
            <apex:outputText value="{!OrderTrainings.Name__c}"/>
        </apex:column>
        <apex:column headerValue="Email">
            <apex:outputText value="{!OrderTrainings.OEmail__c}"/>
        </apex:column>
        <apex:column headerValue="Phone"> 
            <apex:outputText value="{!OrderTrainings.Phone__c}"/> 
        </apex:column>
    </apex:pageBlockTable>
</apex:outputPanel>
1
  • Here now I get an error saying "Unknown property 'VisualforceArrayList.Name__c'" Commented Dec 7, 2016 at 13:32
0

You can perform separate query instead of the subquery. like below:

Class: public List modulesList{get; set;} Public Course__c coursesList{get;set;}

public cNodes(Course__c gp, List p) { modulesList= p; coursesList= gp; } }

Public List hierarchy; Public List getCourse_role() { hierarchy = new List(); List tempparent = [Select Id,Name,recordtype.name
from Course__c where recordtypeid=:'01228000000NuiY']; for (Integer i =0; i< tempparent.size() ; i++) { List tempchildren = [Select Id,name from
Modules__c where Course__r.id= :tempparent[i].Id]; hierarchy.add(new cNodes(tempparent[i],tempchildren)); }
return hierarchy; }

VF page:

  •             <ul>
                 <apex:repeat value="{!parent.modulesList}" var="child">
                    <li><span class="formattextcon"><apex:outputtext style="color:green;" escape="false" value="{!child.name}"/></span>
                      &nbsp;&nbsp;<apex:commandButton value="Start"/>
                    </li>
                 </apex:repeat>  
             </ul>  
        </li>
    </apex:repeat>
    

    You must log in to answer this question.

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