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
Ralph PenceRalph Pence 

Display text in visualforce email only if data is in field

I'm very new to salesforce. I'm working on a visualforce email template that will provide contacts with certain information. I'm trying include a line a variable text.
For example, how can I display "Face Amount: {!relatedTo.Face_Amount__c}" only if there is a value contained in {!relatedTo.Face_Amount__c}?
Pankaj_GanwaniPankaj_Ganwani
Hi Ralph,

Can you please try using display:none; style if relatedTo.Face_Amount__c == null in vf email template?

like:
<span style="{!IF(relatedTo.Face_Amount__c == null, 'display:none;','')}">Face Amount: {!relatedTo.Face_Amount__c}</span>
William LópezWilliam López
Hi Ralph,

You could create a Formula field in the record. Lest calle it "Email_Helper__c".

That formula will be a text like this

IF( ISBLANK( Face_Amount__c) , "", "Face Amount: " + TEXT(Face_Amount__c))

Then in the template use 

{!relatedTo.Email_Helper__c}

That formula will be empty if there is not value and it will have the full text if there is a value.

Of course this solution its valid if you are going to use few text like this, if not you will end up with a lot of fields in your object.

Let me know how it goes.

Regards.

​Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.