You need to sign in to do that
Don't have an account?
huskerwendy
Visualforce Email template not displaying outputField
I'm writing my first visualforce email template and am having a problem with it not displaying the OutputField. I'm not sure what I'm doing wrong.
Here's the controller:
public class getBloomerProductsController { // get the oppty id public id OpptyID {get;set;} //a list to hold the bloomerproducts public List<OpportunityLineItem> BloomerangProducts {get;set;} public getBloomerProductsController() { } public List<OpportunityLineItem> BloomerangProducts() { System.debug('bloomerangProducts is' + BloomerangProducts); System.debug('OpportunityID is'+ OpptyID); return [Select PricebookEntry.Name From OpportunityLineItem WHERE HasBloomerang__c = true and OpportunityID =: OpptyID]; } }
Here's the component:
<apex:component id="getBloomerProducts" controller="getBloomerProductsController" access="global"> <apex:attribute name="OpportunityID" description="This is the Opportunity Id." type="Id" assignTo="{!OpptyID}"/> <table border="1"> <tr> <td><apex:outputText value="Product name"/></td> </tr> <apex:repeat value="{!BloomerangProducts}" var="blp" > <tr> <td><apex:outputField value="{!blp.PricebookEntry.Name}"/></td> </tr> </apex:repeat> </table> </apex:component>
Here's the email template
<messaging:emailTemplate recipientType="Contact" relatedToType="Opportunity" subject="New Firespring Bloomerang Sale" replyTo="sales@firespring.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>A new sale was made to:</p> <br/>Account:{!relatedTo.Account.name} <br/>Contact:{!recipient.Name} <c:getBloomerProductsController OpportunityID="{!relatedTo.Id}"></c:getBloomerProductsController> </font> </body> </html> </messaging:htmlEmailBody> </messaging:emailTemplate>
I thought maybe I was writing the query incorrectly so I changed the query to select only the OpportunityLineItem.Id and it still doesn't display any products. What am I doing wrong?
Thanks!
I think you just need to define the variable as Public.
All Answers
Can you try replacing the controller code with the following:
Thanks for the help Codewizard. I replaced the controller with that code and now I get the error "Error: Unknown property 'getBloomerProductsController.BloomerangProducts"
I think you just need to define the variable as Public.
That fixed it. Thanks!