I have a controller

    public class EmailController
public string AppId{get;set;}

List<App_Child__c> aPRList=[select id,name,status__c from App_Child__c where App__c=:Appid limit 10];

   List<String> status_List=new List<String>();

 public List<String> getStatus() 
     String status;
     for(Approval_Related_Detail__c aPR:aPRList)

        String ab=status;



    return status_List;


I am calling it through a component as below

 <apex:component Controller="EmailController" access="global">
    <apex:attribute name="AppId" assignTo="{!AppId}" type="String" description="Id of the app"/>
     <apex:repeat value="{!Status}" var="string" id="theRepeat">
   <apex:outputText value="{!string}" id="theValue"/><br/>

But I am anot able to see status in my email template .

In email template I am calling component as

<c:EmailComponent AppId="{!relatedto.id}"/>

I am not sure if I am calling the list of string in my component correctly . Please guide here how can I display list values here line by line

  • You need to iterate the list and render each entry separately in the template. Not sure what else is wrong here, if anything.
    – Phil W
    Feb 29, 2020 at 9:07
  • thanks for the reply Phil .But can you please guide me here how to iterate it in the email template
    – user75937
    Feb 29, 2020 at 9:53
  • Being a visualforce template, use visualforce iteration..
    – Phil W
    Feb 29, 2020 at 10:21
  • I tried using the same in my component part but still wont get the list <apex:repeat value="{!status}" var="string" id="theRepeat"> <apex:outputText value="{!string}" id="theValue"/><br/> </apex:repeat>
    – user75937
    Feb 29, 2020 at 13:09
  • Please update the question to show your updated component template.
    – Phil W
    Feb 29, 2020 at 13:29

2 Answers 2


The query is running before the App ID is set. Move the query into the App ID setter to make this work.


The correct pattern for this is:

public class EmailController {
    public appId {get; set;}
    public List<App_Child__c> appChildren {
      get {
        return this.appId != null
          ? [SELECT Status__c FROM App_child__c 
               WHERE App__c = :this.appId]
          : new List<App_Child__c>();
      } private set;

 <apex:component Controller="EmailController" access="global">
  <apex:attribute name="AppId" assignTo="{!appId}" type="String" description="Id of the app"/>
   <apex:repeat value="{!appChildren}" var="child" id="theRepeat">
     <apex:outputText value="{!child.Status__c}" id="theValue"/><br/>

You must log in to answer this question.

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