+ Start a Discussion
NIKALNIKAL 

How to generate specific data elements

I'm new to visualforce so trying to trudge through the learning process.

 

How would I adjust this email template to show case information for a previous month? I want to send an email summarizing case activity for a month for clients.

 

 

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Account"
    subject="Case report for Account: {!relatedTo.name}"
    replyTo="support@acme.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">
 <p>Dear {!recipient.name},</p>
               <p>Below is a list of cases related to the account: {!relatedTo.name}.</p>
         <table border="0" >
                 <tr > 
                     <th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Name</th><th>Priority</th><th>Status</th>
                  </tr>
                  
                  <apex:repeat var="cx" value="{!relatedTo.Cases}">
       <tr>
           <td><a href="http://siscentral.sisfirst.com/ticket-management-sf.aspx?ID=3552">View</a> |  
           <td>{!cx.CaseNumber}</td>
           <td>{!cx.Subject}</td>
           <td>{!cx.Contact.name}</td>
           <td>{!cx.Status}</td>
           <td>{!cx.Priority}</td>
       </tr>
    </apex:repeat>     
    
           </table>
       <p />
 </font>
        </body>
    </html>
    
    </messaging:htmlEmailBody> 
    
    <messaging:plainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of cases related to Account: {!relatedTo.name}
              [ Case Number ] - [ Subject ] - [ Email ] - [ Status ]
<apex:repeat var="cx" value="{!relatedTo.Cases}">
              [ {!cx.CaseNumber} ] - [ {!cx.Subject} ] - [ {!cx.Contact.email} ] - [ {!cx.Status} ]
</apex:repeat>
 For more detailed information login to http://www.salesforce.com
</messaging:plainTextEmailBody>  
</messaging:emailTemplate>

 

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Account"
    subject="Case report for Account: {!relatedTo.name}"
    replyTo="support@acme.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">

 <p>Dear {!recipient.name},</p>
               <p>Below is a list of cases related to the account: {!relatedTo.name}.</p>
         <table border="0" >
                 <tr > 
                     <th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Name</th><th>Priority</th><th>Status</th>
                  </tr>
                  
                  <apex:repeat var="cx" value="{!relatedTo.Cases}">
       <tr>
           <td><a href="http://siscentral.sisfirst.com/ticket-management-sf.aspx?ID=3552">View</a> |  
           <a href="http://siscentral.sisfirst.com/ticket-management-sf.aspx?ID=3552">Edit</a></td>
           <td>{!cx.CaseNumber}</td>
           <td>{!cx.Subject}</td>
           <td>{!cx.Contact.name}</td>
           <td>{!cx.Status}</td>
           <td>{!cx.Priority}</td>
       </tr>
    </apex:repeat>     
    
           </table>
       <p />
 </font>
        </body>
    </html>
    
    </messaging:htmlEmailBody> 
    
    <messaging:plainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of cases related to Account: {!relatedTo.name}

              [ Case Number ] - [ Subject ] - [ Email ] - [ Status ]

<apex:repeat var="cx" value="{!relatedTo.Cases}">
              [ {!cx.CaseNumber} ] - [ {!cx.Subject} ] - [ {!cx.Contact.email} ] - [ {!cx.Status} ]
</apex:repeat>

 For more detailed information login to http://www.salesforce.com
</messaging:plainTextEmailBody>  

</messaging:emailTemplate>

 

 

SatgurSatgur

Hi,

 

You have not clearly stated what is the exact stumbling block here (I mean what is preventing you from displaying last month's case data)?

 

You are retrieving all associated cases for a customer and then building Email Body using the data from each associated case. Would this not include ALL cases (irrespective of which month they belong to) already? Do you see the Case records getting filtered somewhere?

 

We can work out a solution after knowing what the real problem is.

 

Thanks

Satgur