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
MaryaMarya 

Visualforce Email Template - Display filtered Opportunty Report

I'm new to developing for SFDC.  What I am trying to do is create an email report that we can send to our customers showing all of their purchases that have an upcoming contract end date (to encourage renewal). 

 

I have the basic visualforce template created, but what I don't know how to do is:

  • Filter results to only show opportunities that are "Closed Won"
  • Filter results to only show opportunities with Contract End Date (ContractEndDate__c) within the last 30 days AND next 60 days (ie last month and next two months)
  • Sort results by Contract End Date

 

Any help is greatly appreciated.  Thanks!

 

<messaging:emailTemplate subject="Your license summary" recipientType="Contact" relatedToType="Account"> <messaging:htmlEmailBody > <html> <body> <style type="text/css"> table {width: 500px;border: solid #CCC 1px;} th {font-family: Arial, Helvetica, sans-serif;font-size: 11px;background-color: #CCCCCC;text-align:left;} td {font-family: Arial, Helvetica, sans-serif;font-size: 11px; border:dotted #ccc thin;} tr {border: solid #CCC 1px;} td.end-user{text-align:center;border:none;} td.spacer{background-color:#ccc;; height:3px;} </style> <table cellspacing="0" cellpadding="0" align="center"> <tr> <th scope="col">Exp. Date</th> <th scope="col">AV#</th> <th scope="col">PW</th> <th scope="col"># of Licenses</th> <th scope="col">Product</th> </tr> <apex:repeat var="opp" value="{!relatedTo.Opportunities}"> <tr> <td> <apex:outputText value="{0,date, MMMM d', 'yyyy}"> <apex:param value="{!opp.ContractEndDate__c}"/> </apex:outputText> </td> <td>{!opp.License_AV__c}</td> <td>{!opp.License_Password__c}</td> <td><apex:outputField value="{!opp.NumberofLicenses__c}"/></td> <td>{!opp.Product__c}: {!opp.Product_Type__c}</td> </tr> <tr> <td colspan="5" class="end-user"><br /> {!opp.End_User_Company__c} | {!opp.End_User_First_Name__c} {!opp.End_User_Last_Name__c} | {!opp.End_User_Email__c} | {!opp.End_User_Phone__c}</td> </tr> <tr> <td colspan="5" class="end-user">{!opp.End_User_Address_1__c} {!opp.End_User_Address2__c}, {!opp.End_User_City__c}, {!opp.End_User_State__c}, {!opp.End_User_Zip_Code__c} <br /> </td> </tr> <tr> <td colspan="5" class="spacer"></td> </tr></apex:repeat> </table> </body> </html> </messaging:htmlEmailBody> </messaging:emailTemplate>