You need to sign in to do that
Don't have an account?
Christian Szandor Knapp
How to produce correct DateTime Format in Apex: Outputlink / Apex: Param
I am using a visualforce page email template in which Recipient is a Contact, relatedTo is an Event, it dynamically generates an *.ical Attachment. That works just fine by using
What I am not able to achieve is to render a link to Google Calendar that needs the same formatting of StartDateTime/EndDateTime.
I've tried using outputtext as well, but SF prevents me of using that in < a href=''>, if I dont use < a href=''>, some clients wont render the Link as Link, i.e. it is not clickable which is not acceptable. For other reasons, I need to used < messaging:HtmlEmailBody > and cannot use PlainText.
So I tried dissecting my link into params and use Apex:Outputlink.
My approach is as follows:
Is there any way to get that relatedTo.Startdatetime into the format yyyyMMdd followed by HHmmss in an apex param?
If not, can you think of any workarounds that work with the event object? (FYI: SF does not allow to use StartDateTime in a formula expression to create costums fields of the format needed)
<apex:outputText value="{0,date,yyyyMMdd'T'HHmmss}"><apex:param value="{!relatedTo.StartDateTime}" /></apex:outputText>
What I am not able to achieve is to render a link to Google Calendar that needs the same formatting of StartDateTime/EndDateTime.
I've tried using outputtext as well, but SF prevents me of using that in < a href=''>, if I dont use < a href=''>, some clients wont render the Link as Link, i.e. it is not clickable which is not acceptable. For other reasons, I need to used < messaging:HtmlEmailBody > and cannot use PlainText.
So I tried dissecting my link into params and use Apex:Outputlink.
My approach is as follows:
<apex:OutputLink value="https://www.google.com/calendar/render"> Click me <apex:param name="action" value="TEMPLATE"/> <apex:param name="text" value="someValue"/> <apex:param name="dates" value="{relatedTo.Startdatetime}Z/{!relatedTo.EndDateTime)}Z"/> <apex:param name="details" value="someOtherValue"/> <apex:param name="sf" value="true"/> <apex:param name="output" value="xml"/> </apex:OutputLink>
Is there any way to get that relatedTo.Startdatetime into the format yyyyMMdd followed by HHmmss in an apex param?
If not, can you think of any workarounds that work with the event object? (FYI: SF does not allow to use StartDateTime in a formula expression to create costums fields of the format needed)
I ended up using an apex component in the VF Email Template:
We ditched that since we couldn't get TimeZones to work properly in the end. Also, Gmail started to better handle ics attachments, so our usecase was weakened.
Kind regards,
Sz