+ Start a Discussion
David OvellaDavid Ovella 

Why my approval process is sending emails with field values as blank?

Hello there, I'm trying to use an approval process to send emails to my customers.
But the email that I received has fields values as blank, does someone know why?

my approval process has an "email alert" and that email alert has a visualforce email template.
my vf email template
<messaging:emailTemplate subject="{!relatedTo.Asunto_email__c}" recipientType="User" relatedToType="OT__c">
    <messaging:htmlEmailBody >
        Buenos Días<br/><br/>
        
        
        Le envío el presupuesto solicitado:<br/><br/>  
        <c:Envio_Email_Componente />
   </messaging:htmlEmailBody>
</messaging:emailTemplate>
And I receive the email like this:
Buenos Días

Le envío el presupuesto solicitado:

Item 1

Total Gs.: IVA incl.
Total a Pagar Gs.: IVA incl.
Opcional costo de Delivey (Asunción) Gs.: 7.000 IVA incl. (Confirmar Servicio)
Archivo: 
Plazo de Entrega:  hs después de la confirmación
Forma de Pago: 
Requiere Seña: 


And It supposed to look like this:
Buenos Días

Le envío el presupuesto solicitado:

Item 1
tarjetas personales, 9x5cm, impresion digital color, una sola cara, papel ilustracion mate 300g.
Total Gs.: 312.000 IVA incl.
Total a Pagar Gs.: 312.000 IVA incl.
Opcional costo de Delivey (Asunción) Gs.: 7.000 IVA incl. (Confirmar Servicio)
Archivo: Ok
Plazo de Entrega: 24hs después de la confirmación
Forma de Pago: Contado
Requiere Seña: No (100% contra entrega)





my visualforce email template:
 
<apex:component controller="OTPresupuestoControllers" access="global">
    
<apex:repeat var="ot" value="{!cOTList}">
    <table>
        <tr>
            <td><b>Item 1</b></td>
        </tr>
        <tr>
            <td><apex:outputText value="{!ot.OT.Texto_1_fact__c}"/></td>
        </tr>
         <tr>
           <td><apex:outputText value="{!ot.OT.Texto_largo_1_presup__c}"/></td> 
        </tr>
        <tr>
            <td><u>Total Gs.:</u>
                <apex:outputText value=" {!ot.total1} IVA incl."/>
            </td>     
        </tr>

        <tr>
            <td><b><apex:outputText value="Item 2"/></b></td>
        </tr>
        <tr>
            <td><apex:outputText value="{!ot.OT.Texto_2_fact__c}"/></td>
        </tr>
        <tr>
            <td><apex:outputText value="{!ot.OT.Texto_largo_2_presup__c}"/></td>
        </tr>
        <tr>
            <td><u><apex:outputText value="Total Gs.:"/></u>
                <apex:outputText value=" {!ot.total2} IVA incl.""/>
            </td>     
        </tr>

  
        <tr>
            <td><b>
                <apex:outputText value="Total a Pagar Gs.: {!ot.totalapagar} IVA incl.""/>
                </b>
            </td> 
        </tr>  



        <tr>
             <td><b>Archivo: </b> <apex:outputText value=" {!ot.OT.Archivo__c}" /></td>     
        </tr>
        <tr>
             <td><b>Plazo de Entrega: </b> <apex:outputText value=" {!ot.OT.Plazo_de_Entrega__c}hs después de la confirmación" /></td> 
        </tr>
        <tr>
             <td><b>Forma de Pago: </b> <apex:outputText value=" {!ot.OT.Forma_de_Pago__c}" /></td> 
        </tr>
        <tr>
             <td><b>Requiere Seña: </b> <apex:outputText value=" {!ot.OT.Requiere_Sena__c}" /></td> 
        </tr>


</table>
</apex:repeat>
            
</apex:component>



 
Keyur  ModiKeyur Modi
Hi David,

Code which you mention ,in that what you can do is . In component you need to create attribute like id , and in the VF template you need to pass the id for particular record.
For VF template you can reffer below example :
<messaging:emailTemplate subject="{!relatedto.Name} " recipientType="User" relatedToType="Opportunity" >
   <c:Comment opptyId="{!relatedTo.Id}"/>
</messaging:emailTemplate>

for component yuo can reffer below code:
<apex:component controller="QuestionController" access="global" rendered="true">
    <apex:attribute name="opptyId" assignTo="{!currentopptyId}" type="String" description="Id of the opportunity"/>
with help of currentopptyId in your controller class OTPresupuestoControllers  you can query the related records and display it.
 
David OvellaDavid Ovella
Hello Keyur Modi, thanks for answer.

My apex class looks like this:
 
public class OTPresupuestoControllers {
    
    public List<cOT> cOTList{get;set;}


    public OTPresupuestoControllers() {    
        
        //OT List
        this.cOTList = new List<cOT>();
        for(OT__c o : [SELECT Id, Utilizar_DP__c, Texto_largo_1_presup__c, Texto_largo_2_presup__c, Texto_largo_3_presup__c,
                       Texto_largo_4_presup__c, Texto_largo_5_presup__c, Texto_1_fact__c, Texto_2_fact__c, Texto_3_fact__c,
                       Texto_4_fact__c, Texto_5_fact__c, Total_1__c,Total_2__c,Total_3__c,Total_4__c,Total_5__c,
                       Total_a_Pagar__c, Archivo__c, Plazo_de_Entrega__c, Forma_de_Pago__c, Solicitar_Datos_de_Facturacion__c,
                       Requiere_Sena__c, Pre_Factura__r.Cuenta__r.Ex_Fiscal__c, Cant_1__c, Cant_2__c, Cant_3__c, Cant_4__c,
                       Cant_5__c
                       From OT__c  WHERE OT__c.id = :System.currentPageReference().getParameters().get('id')])
            
        {
            cOTList.add(new cOT(o));
        }            
 
    }
      
    
    public class cOT{ //valores que se usa para cuando la Pre_Factura tiene mas de una OT
        public OT__c OT{get; set;}
        public String total1{get;set;}
        public String total2{get;set;}
        public String total3{get;set;}
        public String total4{get;set;}
        public String total5{get;set;}
        public String totalapagar{get;set;}


        public cOT(OT__c o){
            this.OT = o;
            this.total1= NumberToSpanishWords.convertToGs(o.Total_1__c);
            this.total2= NumberToSpanishWords.convertToGs(o.Total_2__c);
            this.total3= NumberToSpanishWords.convertToGs(o.Total_3__c);
            this.total4= NumberToSpanishWords.convertToGs(o.Total_4__c);
            this.total5= NumberToSpanishWords.convertToGs(o.Total_5__c);
            this.totalapagar= NumberToSpanishWords.convertToGs(o.Total_a_Pagar__c);
  
            } 
        }

}


I probed your code:
and I did this in my component (the only way that let me save is with assignTo="{!cOTList.id}"), I tried assignTo="{!o.id}" and assignTo="{!OT__c.id}" but doesn't work.

​<apex:attribute name="otId" assignTo="{!cOTList.id}" type="String" description="Id of the OT__c"/>

and in my vf email template I did this:
<c:Envio_Email_Componente otId="{!relatedTo.Id}"/>

And then I save it, but it gives me this error in my vf email template:
Error occurred trying to load the template for preview: List subscript must be an integer. Please try editing your markup to correct the problem.

I tried this (type="integer") but still show me that error.
​<apex:attribute name="otId" assignTo="{!cOTList.id}" type="integer" description="Id of the OT__c"/>

By anychange you know?
thank you,
David




 
David OvellaDavid Ovella
Hello Keyur Modi,
I was looking this publication and I'm trying to figure out how to make this works.
I still having trouble, and it is in the part of my apex, I don't know how to connect {!currentopptyId} to my Id in the apex class

 
public class OTPresupuestoControllers {
  

    public List<cOT> cOTList{get;set;}
    public String currentopptyId {get;set;}


    public OTPresupuestoControllers() {    
        
        //OT List
        this.cOTList = new List<cOT>();
        for(OT__c o : [SELECT Id, Texto_1_fact__c, Texto_2_fact__c, Total_1__c,Total_2__c,
                       Total_a_Pagar__c, Archivo__c, Plazo_de_Entrega__c, Forma_de_Pago__c, 
                       Requiere_Sena__c, Cant_1__c, Cant_2__c, Nombre_de_la_cuenta__c
                       From OT__c Where Id=:currentopptyId Limit 1])
            
        {
            cOTList.add(new cOT(o));
        }                 
        
    }
      
    
    public class cOT{
        public OT__c OT{get; set;}
        public String total1{get;set;}
        public String total2{get;set;}
        public String totalapagar{get;set;}


        public cOT(OT__c o){
            this.OT = o;
            this.total1= NumberToSpanishWords.convertToGs(o.Total_1__c);
            this.total2= NumberToSpanishWords.convertToGs(o.Total_2__c);
            this.totalapagar= NumberToSpanishWords.convertToGs(o.Total_a_Pagar__c);
  
            } 
        }
    
}