You need to sign in to do that
Don't have an account?
michaelkael
Visualforce email template PDF Controlling Field
Hello
I'm creating a visualforce email template with a PDF file attachment.
I only have one problem, I have to read a value from my account page but this field is a Controlling Field. When I use the tag "<outputField value= ""/> it doesn't work. Do you have a solution?
thanks
Michael
Presumably your VF email template is using account as the relatedto? Also, are you just using
or are you supplying a merge field as the value?
Can you post the template?
See the my template code. The Tag for the filed I want to display is in red.
<messaging:emailTemplate subject="Quote" recipientType="Contact" relatedToType="Quote">
<messaging:plaintextEmailBody >
Hello,
Please find the quotation.
{!$User.FirstName} {!$User.LastName}
{!$User.Title}
{!$User.CompanyName}
Tel: {!$User.Phone}
Mobile: {!$User.MobilePhone}
Email: {!$User.Email}
</messaging:plaintextEmailBody>
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">
<html>
<head>
<style>
table {
width:100%;
border-collapse:collapse;
margin-top:1px;
margin-bottom:2px;}
.letter td, .end td{
padding-bottom:20px;
}
p, h4 {
margin-top: 1px;
margin-bottom:1px;
}
.footer p{
padding:1px;
text-align: center;
font-size: 6pt;
font-color:"grey";
}
.productList td,.productList th{
border-style: solid;
border-width: 1px;
border-color: "black";
}
</style>
</head>
<body>
<div id="test"></div>
<table class="letter">
<tr>
<td style="text-align:right;"><img src="{!$Resource.RedLionLogo}" /></td>
</tr>
<tr>
<td><strong><p>{!relatedTo.Opportunity.Account.Name}</p>
<p>{!relatedTo.Opportunity.Account.BillingStreet}</p>
<p>{!relatedTo.Opportunity.Account.BillingCity}, {!relatedTo.Opportunity.Account.BillingPostalCode}</p>
<p>{!relatedTo.Opportunity.Account.BillingCountry}</p></strong>
</td>
</tr>
<tr>
<td> <strong>For the attention of:</strong> {!relatedTo.Contact.Name}</td>
</tr>
<tr>
<td><strong>Date: </strong> {!DAY(today())}/{!MONTH(today())}/{!YEAR(today())}</td>
</tr>
<tr>
<td><strong>Quote Reference: {!relatedTo.QuoteNumber}-{!relatedTo.Name}</strong> </td>
</tr>
<tr>
<td><apex:outputText escape="false" value="{!relatedTo.Quote_Notes_to_customer__c}" /></td>
</tr>
</table>
<div style="page-break-after:always;"> </div>
<h3>Products list:</h3>
<table class="productList" style="margin-bottom:20px;margin-top:20px;">
<tr>
<th> Product</th><th>Description</th><th>Quantity</th><th>Net Price</th><th>Total Price</th>
</tr>
<apex:repeat var="kot" value="{!relatedTo.QuoteLineItems}">
<tr>
<td>{!kot.PriceBookEntry.name}</td>
<td>{!kot.Product_Description_EN__c}</td>
<td style="text-align:center;">{!ROUND(kot.Quantity,0)}</td>
<td align="right">{!kot.CurrencyIsoCode} {!kot.UnitPrice} </td>
<td align="right">{!kot.CurrencyIsoCode} {!kot.TotalPrice} </td>
</tr>
</apex:repeat>
<tr>
<td colspan="3" style="border:none;"></td>
<td style="text-align:right;"><strong>Grand total:</strong></td><td style="text-align:right;">{!relatedTo.CurrencyIsoCode} {!relatedTo.GrandTotal} </td>
</tr>
</table>
<table class="end">
<tr>
<td>
<p><strong>Prices:</strong> Prices are in <strong>{!relatedTo.CurrencyIsoCode}</strong>. Net price/total price/grand total is after offered discount.</p>
<p><strong> Transport costs:</strong> <apex:OutputField value="{!relatedTo.Opportunity.Account.Transportcostweeklyshipment__c}"/> ///20GBP if order value 625GBP, 31 GBP if order value 625GBP.</p>
<p><Strong> Payment Term:</strong> {!relatedTo.Opportunity.Account.Paymentterms__c}. </p>
<p><strong>Delivery time:</strong> 3- 4 days ARO (subject to stocks remaining unsold at time of receipt of order). </p>
<p><strong> Minimum order value:</strong> 200 {!relatedTo.CurrencyIsoCode}.</p>
<p><strong>All orders are accepted according to Red Lion <a name="T&C" href="http://store.redlion.net/store/terms-conditions.html">Terms and Conditions.</a></strong></p>
</td>
</tr>
<tr>
<td>We trust the above meets your requirements.</td>
</tr>
<tr>
<td>We look forward to your valued order. Please indicate the following Quote Number: <strong>{!relatedTo.QuoteNumber}-{!relatedTo.Name}</strong></td>
</tr>
<tr>
<td>with your order or in any correspondence relating to this quote.</td>
</tr>
<tr>
<td>With kind regards,</td>
</tr>
</table>
<table>
<tr>
<td><p>{!$User.FirstName} {!$User.LastName}</p>
<p>{!$User.Title}</p>
<p>{!$User.CompanyName}</p></td>
</tr>
<tr>
<td><p>Tel: {!$User.Phone}</p>
<p>Mobile: {!$User.MobilePhone}</p>
<p>Email: {!$User.Email}</p>
</td>
</tr>
</table>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>
Hmm. It may be the number of levels that you are going down. Have you tried traversing one relationship at a time to see if that is the case. E.g.
If it is the case that the related objects aren't populated, you'll need to look at using a custom component and controller inside your template to pull back all the additional information.
I don't that is the issue because I have the same amount of level with this field {!relatedTo.Opportunity.Account.Paymentterms__c} and it works.
The field I want to read is a Picklist. Does it special thing to know with this kind of fields?
michael
I can't think of anything special about picklist fields - it should just come out as text. You could try replacing the outputfield with an outputtext, but I doubt that will make a difference.
The only other suggestion I can make is to check the field level security.
Hello
I have got it!! It was a stupid mistake from me. I don't want to say it. I'm too shameful.
Thanks for your help anyway
Bye
michael