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
JimInSRQJimInSRQ 

VisualForce Email If Checkbox Field = True then output

I have a VF Email on which I want to output the text "Backup restored from backup dated" {!relatedTo.ZWave_Date_of_Backup__c} if the checkbox {!relatedTo.ZWave_Backup_Restored__c} = True.  Not sure of the syntax.   This works...
{!if(relatedto.ZWave_Backup_Restored__c, (relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}
but when true, I need to concatenate "Was restored from backup created on " with (relatedTo.ZWave_Date_of_Backup__c),  using this syntax I get an error Syntax error. Missing ')
{!if(relatedto.ZWave_Backup_Restored__c, "Were restored with backup from " AND (relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}
OR 
{!if(relatedto.ZWave_Backup_Restored__c, "Were restored with backup from " (relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}
using this syntax I get an error Incorrect parameter type for operator '&'. Expected Text, received Date
{!if(relatedto.ZWave_Backup_Restored__c, "Were restored with backup from " & (relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}

 
Best Answer chosen by JimInSRQ
Alain CabonAlain Cabon
Hi,

The concatenation operator is the sign "+" but do you need to format the date?
 
{!if( {relatedto.ZWave_Backup_Restored__c, "Were restored with backup from " + TEXT(relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}

There will be many other solutions.

Regards

All Answers

Alain CabonAlain Cabon
Hi,

The concatenation operator is the sign "+" but do you need to format the date?
 
{!if( {relatedto.ZWave_Backup_Restored__c, "Were restored with backup from " + TEXT(relatedTo.ZWave_Date_of_Backup__c), "No Backup to restore")}

There will be many other solutions.

Regards
This was selected as the best answer
Alain CabonAlain Cabon
A sample for formatting the date: 
<apex:outputText value="{0, date, MMMM d','  yyyy}">
    <apex:param value="{!contact.Birthdate}" /> 
</apex:outputText>

https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Regards