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
CathalCathal 

Help with apex:outputField in visual force template

I'm trying to create a VF email template. I need to use apex:outputField rather than apex:outputText because there is a problem with GMT daylight savings when I output a date that is on summer time. apex:outputField should help me do this 

 

My code reads like this:

 

 

<messaging:emailTemplate subject="Test" recipientType="Contact" relatedToType="Work__c" >
<messaging:htmlemailbody >

<apex:variable var="date" value="{!relatedTo.Start__c}"/>
            <apex:outputField value="{0, date, EEEE d, MMMM yyyy, hh:mm a}">
                                <apex:param value="{!date}" />
                            </apex:outputField>
                            

</messaging:htmlemailbody>
</messaging:emailTemplate>

 

but when I select my template  I'm getting the error:" value for outputField is not a dynamic binding!"

 

So I read up on dynamic binding in the VF guide but I'm none the wiser.

 

Can anybody help?

 

Alex_ConfigeroAlex_Configero

 

Unfortunately you can't use param with outputfield, the value attribute needs to be an actual field. What edition do you have?

 

You could do what you need by using a simple component where you need the date displayed.

 

This thread has some sample code to calculate the date correctly:

 

http://boards.developerforce.com/t5/Visualforce-Development/Showing-date-time-with-Apex-outputtext/td-p/208975

 

and this page shows you how to add a component to a vf email template:

 

http://gokubi.com/archives/visual-force-email-templates-2

 

Your component is going to be much simpler than that of course, just returning that date variable.

DohDoh

I had a similar issue and I believe the issue you faced is that you probably have internationalization working in the form of multi-currency. When activated you cannot use <apex:outputField> and must use <apex:outputText> with all the issues related to displaying currency fields and dates.

 

I have raised this issue on IDEAS.