You need to sign in to do that
Don't have an account?

My email template is sending information with some fields in blank
I created a visual email template that works with:
--a custom object called OT__c,
--a visualforce component called OTComponente, and
--an apex class called OTPresupuesto.
My problem is when I receive the email, it has some fields in blank, I think it has to do with the id of the custom object.
Specifically this part:
and when I put the "From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')" the email looks like this (the component doesn't even appear):
this is my apex class OTPresupuesto
and my visual component OTComponente
this is my visual email template called EnvioPresupTemaplate
--a custom object called OT__c,
--a visualforce component called OTComponente, and
--an apex class called OTPresupuesto.
My problem is when I receive the email, it has some fields in blank, I think it has to do with the id of the custom object.
Specifically this part:
From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')when I put in my apex class just the "From OT__c" without specifying my Id, the email I recieve looks like this:
Nuestra Ref.: Sucursal: Fecha:24/08/2015 Total a Pagar:0,00 Saldo a Pagar:0,00 Sub Total:0,00 Nombre: RUC: Name: Gracias por elegir Maker! Saludos Cordiales, El equipo de Makerxmail
and when I put the "From OT__c Where Id=:System.currentPagereference().getParameters().get('Id')" the email looks like this (the component doesn't even appear):
Nuestra Ref.: Sucursal: Fecha:24/08/2015 Gracias por elegir Maker! Saludos Cordiales, El equipo de Makerxmail
this is my apex class OTPresupuesto
public with sharing class OTPresupuesto { public List<fact> factList{get;set;} //Constructor public OTPresupuesto() { this.factList = new List<fact>(); for(OT__c ot2 :[Select Name, Nombre_de_la_Cuenta__c, Sub_Total__c, RUC__c, Total_a_Pagar__c,Saldo_a_Pagar__c From OT__c Where Id=:System.currentPagereference().getParameters().get('Id') LIMIT 1]) { factList.add(new fact(ot2)); } } public class fact{ public OT__c OT{get; set;} public string saldoPagar {get; set;} public string subTotal {get; set;} public string totalPagar {get; set;} public fact(OT__c ot2){ this.OT = ot2; this.saldoPagar= NumberToSpanishWords.convertToEU(ot2.Saldo_a_Pagar__c); this.subTotal= NumberToSpanishWords.convertToEU(ot2.Sub_Total__c); this.totalPagar= NumberToSpanishWords.convertToEU(ot2.Total_a_Pagar__c); } } }
and my visual component OTComponente
<apex:component controller="OTPresupuesto" access="global"> <apex:repeat var="as" value="{!factList}"> Total a Pagar: <apex:outputText value="{!as.totalPagar}"/><br/> Saldo a Pagar: <apex:outputText value="{!as.saldoPagar}"/> <br/> Sub Total: <apex:outputText value="{!as.subTotal}"/><br/> Nombre: <apex:outputText value="{!as.OT.Nombre_de_la_Cuenta__c}"/><br/> RUC: <apex:outputText value="{!as.OT.RUC__c}"/> <br/> Name: <apex:outputText value="{!as.OT.Name}"/> <br/> </apex:repeat> </apex:component>
this is my visual email template called EnvioPresupTemaplate
<messaging:emailTemplate subject="RE: {!relatedTo.Asunto_email__c}" recipientType="User" relatedToType="OT__c"> <messaging:htmlEmailBody > <br/> <b>Nuestra Ref.:</b><apex:outputText value="{!relatedTo.Name}"/><br/> Sucursal:<apex:outputField value="{!relatedTo.Sucursal__c}"/><br/> Fecha:<apex:outputField value="{!relatedTo.Fecha__c}"/><br/> <br/><c:OTComponente /> <br/> <br/> Gracias por elegir Maker!<br/> Saludos Cordiales,<br/> El equipo de Makerxmail </messaging:htmlEmailBody> </messaging:emailTemplate>
Please do the below changes in your code:
In Apex Class OTPresupuesto
In Component OTComponente :
In VF EMail Template EnvioPresupTemaplate Please let me know if you need more help.
Thanks,
Vishal
All Answers
Please do the below changes in your code:
In Apex Class OTPresupuesto
In Component OTComponente :
In VF EMail Template EnvioPresupTemaplate Please let me know if you need more help.
Thanks,
Vishal
I replaced my code with yours, and it looks ok until I try to send an email, it appears one error
i'm trying to understand but doesn't give any details about what it may be wrong just the "Attempt to de reference a null object"
I have tried in my personal org and its working fine, not sure why it is not working for you, if possible can you share your org with me for half an hour. My email id is vishal.er.gupta@gmail.com or we can discuss on Skype at vishal.gupta293
Thanks,
Vishal