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
MarniMarni 

SalesForce ID and Full Date/Time Appears in VF Email Template

I have a Visualforce email template and it seems that thSalesForce ID of an Account is appearing rather than the name of the Account Name. 

 

The field I am referencing is a Lookup field on the custom object Policy to an Account.  I am having the same issue with a Lookup field on this custom object to a Contact.  The code I am using for these fields is:

 

Insured: {!relatedTo.Insured__c}

Underwriter: {!relatedTo.Underwriter__c}

 

I am also pulling in two date fields but rather than showing that appears on the screen (e.g. 4/1/2010) it is showing Thu Apr 01 00:00:00 GMT 2010 .  How can I get it to just show MM/DD/YYYY.  The code I am using for these fields is:

 

Effective Date: {!relatedTo.Effective_Date__c}
Expiration Date: {!relatedTo.Expiration_Date__c}

 

Any help is greatly appreciated!  Thanks

Best Answer chosen by Admin (Salesforce Developers) 
MarniMarni

I was able to work with the date code you provided and I was able to get it to work.  I used:

 

<apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!relatedTo.Effective_Date__c}"/></apex:outputText>

 

Thanks for all your help!

All Answers

kiranmutturukiranmutturu

try like this Insured: {!relatedTo.Insured__r.name}

and for the date u can use like this

 

 

<apex:outputText value="{0,date,MM/DD/YYYY}" style="font-style:Georgia;font-size:10pt;">
                                    <apex:param value="{!O.Effective_Date__c}"/> 
</apex:outputtext>
MarniMarni

Thanks for your help!  The SalesForce ID solution worked but with the date solution, I got a number of errors.  I have tried a number of scenarios to resolve but keep getting new errors.  Below is the updated code I had put it in and here is the error I get:

 

Error: X90_Day_Policy_Expiration_Notification line 8, column 170: The element type "messaging:plaintextemailbody" must be terminated by the matching end-tag "</messaging:plaintextemailbody>"

Error: The element type "messaging:plaintextemailbody" must be terminated by the matching end-tag "</messaging:plaintextemailbody>".

 

 

<messaging:emailTemplate subject="90 Day Policy Expiration: {!relatedTo.name}" recipientType="Contact" relatedToType="Policy__c">
<messaging:plainTextEmailBody >
The following policy has an Expiration Date that is within 90 days from today.

Details:
Policy: {!relatedTo.Name}
Insured: {!relatedTo.Insured__r.name}
Effective Date: <apex:outputText></apex:outputText> value="{0,date,MM/DD/YYYY}" style="font-style:Georgia;font-size:10pt;"><apex:param value="{!O.Effective_Date__c}"/></apex:outputtext>
Expiration Date: {!relatedTo.Expiration_Date__c}
Underwriter: {!relatedTo.Underwriter__r.name}
Underwriting Branch Office: {!relatedTo.Underwriting_Branch_Office__c}

RELATED CLAIMS:

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

MarniMarni

I was able to work with the date code you provided and I was able to get it to work.  I used:

 

<apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!relatedTo.Effective_Date__c}"/></apex:outputText>

 

Thanks for all your help!

This was selected as the best answer