You need to sign in to do that
Don't have an account?
Lago S.p.a.
Use parent object field on visualforce template
Hi everyone! I've a little problem with a visualforce template.
I'd like to add in this template various fields on account parent object, but when I test with a test contact, I don't see any field of the related account :(
Here's a part of my code:
<messaging:emailTemplate recipientType="Contact"
relatedToType="Contact"
subject="CONDICIONES COMERCIALES PARA EL AÑO 2020"
replyTo="web@lago.it"
>
<messaging:htmlEmailBody >
<html>
<body>
<div>
<img src="https://www.lago.it/wp-content/uploads/2020/02/header-mail.png" style="width:60%;margin:5% 40% 5% 0%" border="0"></img>
</div>
<div style="margin-left: 40%;width:60%" align="left">
<apex:variable var="Name" value="{!relatedTo.Account.Name}" />
{!Name}<br/>
{!relatedTo.Account.BillingStreet},{!relatedTo.Account.BillingCity}<br/>
{!relatedTo.Account.BillingPostalCode},{!relatedTo.Account.BillingCountry}<br/>
<apex:outputText id="PIVA" rendered="{!IF(relatedTo.Account.piva__c <> '' , 'true', 'false')}">
CIF: {!relatedTo.Account.piva__c}<br/> etc etc....
Any help will be appreciated..Have a nice day :)
I'd like to add in this template various fields on account parent object, but when I test with a test contact, I don't see any field of the related account :(
Here's a part of my code:
<messaging:emailTemplate recipientType="Contact"
relatedToType="Contact"
subject="CONDICIONES COMERCIALES PARA EL AÑO 2020"
replyTo="web@lago.it"
>
<messaging:htmlEmailBody >
<html>
<body>
<div>
<img src="https://www.lago.it/wp-content/uploads/2020/02/header-mail.png" style="width:60%;margin:5% 40% 5% 0%" border="0"></img>
</div>
<div style="margin-left: 40%;width:60%" align="left">
<apex:variable var="Name" value="{!relatedTo.Account.Name}" />
{!Name}<br/>
{!relatedTo.Account.BillingStreet},{!relatedTo.Account.BillingCity}<br/>
{!relatedTo.Account.BillingPostalCode},{!relatedTo.Account.BillingCountry}<br/>
<apex:outputText id="PIVA" rendered="{!IF(relatedTo.Account.piva__c <> '' , 'true', 'false')}">
CIF: {!relatedTo.Account.piva__c}<br/> etc etc....
Any help will be appreciated..Have a nice day :)
So, my code was right. The preview in send email button from contact is the real issue. Have a nice day
All Answers
Try using VF component and search for the fields of the Parent Account's fields on it's extension class' constructor.
So, my code was right. The preview in send email button from contact is the real issue. Have a nice day