function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amitverma1195@gmail.comamitverma1195@gmail.com 

Visualforce template coming 100% empty including subject and hard coded text in body

We are firing a visualforce template via workflow rule, work flow rule is on Opportunity and it is coming 100% empty in some cases and in some cases it's working fine. When we test the template manually it's working fine. Is there any limitation for visualforce template or what might be the issue?

Thanks in advance.
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

Check out this post, it might be useful:
http://salesforce.stackexchange.com/questions/46100/email-alert-using-visualforce-email-template-produces-empty-email (http://salesforce.stackexchange.com/questions/46100/email-alert-using-visualforce-email-template-produces-empty-email" target="_blank)

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
amitverma1195@gmail.comamitverma1195@gmail.com
Thanks Zuinglio,

We are using component for vf template, please find the code below, if there is an issue with component then hard coded text in subject and body should be there, it's not even populating that. Is there any issue with receivers email account settings, that's why he is not able to see anything?
/-------------Visualforce template--------------------------/

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Opportunity"
    subject="Your August is on its way"
    replyTo="support@abc.com" >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
               TD  {font-size: 11px; font-face: verdana } 
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
                  <font face="arial" size="2">
                  <apex:image id="theImage" value="http://i.ihjhj.com/QF7OleT.png"/>
                  <br></br>
                  <br></br>
        <c:ProductShipped OPPId="{!relatedTo.Id}" />
<p>Here is what is included in your package:</p>
  <table border="0" >
                 <tr > 
                     <th align="left">Product Name</th><th align="left">Quantity</th>
                  </tr>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
       <tr>
           <td>{!opp.PriceBookEntry.name}</td>
           
           <td>{!ROUND(opp.Quantity,0)}</td>
       </tr>
    </apex:repeat>                 
       </table>
<P>Thank you,
<br>The August Team</br></p>

 </font>
       
        </body>
    </html>
</messaging:htmlEmailBody> 
</messaging:emailTemplate>
/---------------ends------------------------/



/---------------------Apex Component----------------------/

<apex:component controller="ProductShipped" access="global"> <apex:attribute name="OPPId" type="Id" description="Id of the Opportunity" assignTo="{!OPPorId}"/> <apex:repeat value="{!opptys}" var="o"> Hello {!o.Account.PersonContact.FirstName}, <br/><br/> We are excited to let you know your August Smart Lock is on it way! Your lock left our warehouse via {!o.Fulfillment_Courier__c} with a tracking number of {!o.Fulfillment_NumberF__c}. Keep an eye out for your new August to arrive. If you have any questions please contact us. </apex:repeat> <!-- <apex:repeat value="{!opp}" var="o"> Hello {!o.Account.PersonContact.FirstName}, <br/><br/> We are excited to let you know your August Smart Lock is on it way! Your lock left our warehouse via {!o.Fulfillment_Courier__c} with a tracking number of {!o.Fulfillment_NumberF__c}. Keep an eye out for your new August to arrive. If you have any questions please contact us. </apex:repeat> --> </apex:component>
/------------------------ends-----------------------/

/--------------------Apex Class:-----------------------/
public with sharing class ProductShipped {
     public Id OPPorId {get;set;}
    public list<Opportunity> getopptys()
    {
         list<Opportunity> oppty ;

       // system.debug('OPPorId');
      //  List<OpportunityLineItem> oppty;
       
        oppty =[select name,opportunity.Account.PersonContact.FirstName,Fulfillment_NumberF__c,Fulfillment_Courier__c from opportunity where id=:OPPorId limit 1];
        
      // oppty = [SELECT PricebookEntry.name,Quantity  FROM OpportunityLineItem  WHERE OpportunityId  =: OPPorId];
       //      system.debug('oppty----------'+oppty);
        
        return oppty;
    }

}


Thanks
 
SF AdminSF Admin
Hi

 your templates looks fine.I think your workflow rule has some limitations in it. can you also share workflow rule .?

Regards
amitverma1195@gmail.comamitverma1195@gmail.com
Hi,

Please find the workflow rule Below:

User-added image

Thanks
Mark MoggyMark Moggy

Your Workflow rule is just fine Amit and so is your Visualforce code - good job!

I have the same problem, and I have read all the posted work arounds like "do it in HTML", and I think the bottom line is that Salesforce can't can't be bothered to fix it.

BTW it doesnt work in Process Builder either.