I have a table that uses repeat in a visualforce template. This uses a component with a controller to query a list of records.

Each record has a many child records that I want in one cell. The query works in workbench but when I try to put the results in the table (under a repeat) I get an error "Invalid field Sku__r for SObject" because the field is part of child not parent. I do not want a row for every child, I need a row per parent record with child records (one field only) in one cell. Below is my code:

**********Visualforce Email Template**********

  body button, body .x-btn, body .btn, body .btnDisabled, body .btnCancel, 
body .menuButton .menuButtonButton {
color: #333;
margin: 1px;
padding: 2px 3px;
border: 1px solid #b5b5b5;
border-bottom-color: #7f7f7f;
background: #e8e8e9 url('/img/alohaSkin/btn_sprite.png') repeat-x right top;
font-weight: bold;
font-size: 1.5em !important;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;

<style type="text/css">
        body {font-family: Open Sans size: 12pt;}

        table {
        border-width: 0px;
        border-spacing: 0px;
        width: 700px;
        background-color: #FFFFFF;

    td {
        border-width: 0px;
        padding: 4px;
        border-style: solid;
        border-color: #000000;

        width: 700px;


    th { 
        color: #FFFFFF;
        border-width: 0px ;
        padding: 4px ;
        border-style: solid ;
        border-color: #000000;
        background-color: #900000;
        width: 700px;


<br>  <font size="4.5" ><b>New eval requests may be locked after exceeding 
the % Past Due limit. Currently this limit is 10%. You can see your 
outstanding evals, your past due evals, and % of past due below. </b></font>
<div style="font-size:24px;">

 <BR> <c:EvalContactEmail EvalId="{!relatedTo.Id}"/></BR>

 <br> <apex:panelGrid columns="2" id="theGrid" border="1" frame="border" 
 cellpadding="3px" width="500px" > 
    <apex:outputText value="% of Past Due:" id="theFith"/>
    <apex:outputText style="{!if(Relatedto.Eval_Past_Due_Over_Threshold__c = 
 true,'float:right; background-color: #900000; color: 
 #FFFFFF;','float:right;')}" value="{!Relatedto.Past_Due__c}%" 
     <apex:outputText value="Past Due Amount:" id="theFirst"/>
    <apex:outputText style="float:right;" value="{0, number, currency}" 
 id="theSecond"><apex:param value="{!relatedTo.PR_Past_Due_Evals__c}"/> 
    <apex:outputText value="Outstanding Amount:" id="theThird"/>
    <apex:outputText style="float:right;" value="{0, number, currency}"  
 id="theFourth"><apex:param value="{!RelatedTo.PR_Total_Outstanding__c}"/> 



<font size="3.5" >  <br> <a style="color:red" id="theLink" name="Outstanding 
Evaluations" href="https://viewsonic.my.salesforce.com/a0y?
fcf=00B12000008hqJM">My Outstanding Evaluations</a>
          <font size="3.5" >  <br> <a style="color:red" id="theLink" 
 name="Outstanding Evaluations" 
 fcf=00B12000008CjOs&rolodexIndex=-1&page=1">My Past Due Evaluations</a>



  <apex:component controller="EvalConEmail" access="global">
  <apex:attribute name="EvalId" type="Id" description="Id of the account" 
  <table border="0" >
             <tr > 
                 <th>Billing Account</th><th>Shipping Contact</th>
<th>Shipping Account</th><th>Related Opportunity</th><th>Eval Status</th>
 <apex:repeat var="e" value="{!evals}" >
        <td><apex:outputlink value="
        <!-- <td>{!e.Product_Name__r.Name&' '&e.Product_Name_2__r.Name&' 
'&e.Product_Name_3__r.Name&' '&e.Product_Name_4__r.Name}</td>-->



public class EvalConEmail {

public Id conid {get;set;}
public List<Eval_Request__c> getevals()
    List<Eval_Request__c> evals;
      evals = [SELECT 
Shipping_Contact_Name__r.Account.Name, Eval_Request__c.Opportunity_Name__c, 
 Billing_Account__c,Billing_Account__r.Name,(Select Sku__r.Name from 
Eval_Unit_Details__r eu)                   
                FROM Eval_Request__c e
                WHERE Evaluation_Owner__c =: conid and  (Product_Status__c 
 ='Past Due' or Product_Status__c ='Outstanding (Not Past Due)') ];

                system.debug('evals '+evals);
    return evals;

evals is a list of Eval_Request__c


Sku__r is not on the Eval_Request__c object, it is on the Eval_Unit_Details__r object/subquery

Your best bet would be to use a wrapper class here so you can set the value of the String you want to display. Otherwise you will have to iterate over Eval_Unit_Details__r to display each Sku__r.Name

| improve this answer | |

I figured out how to get this done. I added a repeat within the repeat for the child object. It worked perfectly, I guess I just needed to take a walk.

 <apex:repeat var="eu" value="{!e.Eval_Unit_Details__r}">{!eu.Sku__r.Name}<br>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.