• Solo
  • NEWBIE
  • 124 Points
  • Member since 2010
  • SalesForce (SFDC) Architect / Analyst / Developer
  • WebSolo Inc.


  • Chatter
    Feed
  • 3
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 24
    Replies

Hello,

 

I am trying to setup a date time stamp at the top of an email template so it would look something like this:

 

Jul 15 2009 10:01AM

 

I have tried using the {!Now()} function in my email template but it comes out as GMT which is a few hours ahead of us here in CST.  

 

Could anyone tell me a better way to add today's date to the top of an email?  I've been all through the discussion boards and Technical Library and can't seem to find it.  If I missed an example or discription a link to that would be great too.

 

Thanks in advance,

Marc Petersen

I have created a few custom components for the home page and was wondering if there is an easy way to hide the name of the component when it is displayed?  It appears that SFDC takes the name of the custom component and puts it in a h2 tag. 

I'm thinking I can write some JavaScript to locate the specific h2 tags I want to hide (clearing out the innerHTML) and embed that in the "Messages and Alerts" component, but I wanted to see if there was a better way to accomplish this.  Any suggestions?

I am testing a number of insert routines for a custom object using the APIs.  I noticed in the salesforce.com setup area, there does not appear to be a way to mass delete rows in a custom object.

Is there a recommended way to mass delete rows from a custom object?  I have been unable to find the right message in the various posts.

I want to delete the rows I added so I can retest as needed.  Do I need to create a separate program to select the rows by create date and delete each one.

Thanks

Mike Schumacher

Page code:
<apex:page renderAs="pdf">
        <h1>TestPdfPage</h1>
</apex:page>
 
Page URL:
http://wsdev-cityoftoronto.cs41.force.com/TestPdfPage
You can open the page without login
Let’s try to attach the page to email and send it
We will try to send as Sys Admin and Site Guest User
Code:
         List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
         PageReference pdf = Page.TestPdfPage;
         pdf.setRedirect(true);
         Blob b = pdf.getContent();   
         Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
         efa.setFileName('TestPage.pdf');
         efa.setBody(b);
         Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
         List<String> adresses= new List<String>();
         adresses.add('vsenko11@gmail.com');
         email.setToAddresses(adresses);
         String body= 'Test Body';
         email.setSubject('Test Subject');
         email.setHtmlBody(body);
         email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
         mails.Add(email);
         Messaging.sendEmail(mails);
 
When sending as Sys Admin, all Ok 

 
 
If we do the same as Site Guest User got error when opening PDF

If open in NotePad  first file is Ok but second is appears as HTML file.
 
 


 
  • August 19, 2016
  • Like
  • 0

Hello All,

Just want to share my experience in creating Visualforce Email template where you want to display date and time in User timezone

 

***Overview
You are in MST time zone.
Let's say we have Date/Time field TaskDateTime__c and use it in Visualforce email template to show recipient the time in email.

<apex:outputText value="{0,date,EEEE, MMMM d, yyyy, HH:mm:ss}"><apex:param value="{!RelatedTo.TaskDateTime__c}" /></apex:outputText>

 

In email time will be converted and showed to GMT instead of EST.

 

The outputField (which convert time to user locale automatically) does not
work in Visualforce Email templates (not supported).

 

So how do I tell to display in Visualforce Email template time in User
timezone? For example MST?

 

***Implementation Details (worarounds)***

 

I found two workarounds:

 

Workaround 1: Use Controller class for the Component to use in template

In order to format the date in various TimeZone in Email Template, we can follow the steps:

1. First create a Controller class for the Component

Setup|App Setup|Develop|Apex Classes|New

Formatted_DateTime_Controller Class Code
----------------------------------------------------------

public class controller_formatted_datetime
{
public DateTime date_time { get; set; } //property that reads the datetime value from component attribute tag
public String defined_format { get; set;} //property that reads the string value from component attribute tag
public String getFormattedDatetime()
{
if (date_time == null) {return ''; }
else { if (defined_format == null) {
return date_time.format(); //return the full date/time in user's locale and time zone
}
else { return date_time.format(defined_format,'MST'); //Specify Time zone like IST,CST
}}}}

 

2. Create a Component

Setup|App Setup|Develop|Components

VF Component Code (Name: VFEmailTempComp)

<apex:component access="global" controller="controller_formatted_datetime">{!FormattedDatetime}
<apex:attribute assignTo="{!date_time}" description="The DateTime value to be rendered" name="date_time_value" type="DateTime"></apex:attribute>
<apex:attribute assignTo="{!defined_format}" description="The optional format to use for the DateTime value to be rendered" name="date_time_format" type="String"></apex:attribute>
</apex:component>

 

 

3. Create an Email Template and embed the component.

Setup|Administration Setup|Communication Templates|Email Templates

Email Template Code
---------------------------------

<messaging:emailTemplate subject="Testing DateTime Format" recipientType="Contact" >
<messaging:plainTextEmailBody >
Formatted: <c:VFEmailTempComp date_time_value="{!NOW()}" date_time_format="EEE MMM d kk:mm:ss z yyyy" />
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

It will display current time in MST timezone.


Workaround 2: Calculate difference in the apex:param value (for MST (-7) it will be 7/24=0.291666666

Date: <apex:outputText value="{0,date,EEEE, MMMM d, yyyy}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText>
Time: <apex:outputText value="{0,date,h:ma}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText> MST

  

  • August 28, 2012
  • Like
  • 4

Hello All,

 

Just want to share my experinse in creating VF Inline Injection ("snippets") with preloader image

 

Overview

Using standard (native) SFDC page layouts is the most efficient and recommended way by Salesforce (SF) to present an object’s information. But in some cases where a page layout requires advanced VF logic and features, VF injection (inline embedding) need to be used.

To do VF injection, a custom VF page with controller extension has to be created for each VF injection.  VF page must use the standard controller (e.g. Account controller in case if VF injection is used on Account page), then this VF page can be embedded to page layout.

 

Implementation Details (example)

Create the Visualforce page and Controlles

You have to create the Visualforce page and controller extension. Our Visualforce page must use the standard object controller it will be assigned. After saving it will show up on the list of available Visualforce pages on the object’s page layout(s).

 

Code example

Visual page start:

<apex:page standardcontroller="Account" extensions="EXTENTION" cache="true"> <apex:outputPanel id="errMsg"> <apex:pageMessages /> </apex:outputPanel> ... your VF page code here ...

 

Design Considerations and implementation tips

 

  • VF page injections do not influence parent page performance.   They work and load in individual HTML iframe.
  • Apply general CSS styles for common elements in <style> section in the top of the VS page.
  • Do not apply inconsistent with parent and general for SF pages styles.  For example <center><font color="#000000">Industry Team Type</font></center>.  In native SF's interface, all fields in related objects aligned to the left by default.
  • Do not apply code like - <td width="16.66%" - in most cases default width works properly.
  • Keep the code structured and easy to read (use Tab to align the code lines by sections).
  • Interface use-ability is a priority #1.  Keep UI easy to understand and work with.  Move allAJAXworking areas (to add or edit records) to the top of the VF page and set all field and buttons in one row (to avoid horizontal scrolling).
  • In case the VF page has dependent fields (with dynamic pickup values changed by AJAX request), always use re-render action listener and re-rendering action status string (for example "Updating picklist values...") that will appear on the top of the page in good visible area.
  • Use the same action status string style appearance to indicate "Requesting...", "Saving..." and "Updating..." AJAXactions.
  • The height of the iframe with embedded VF page will be constant – so apply the height that would cover average list of record.  Other records will be available for review by vertical scrolling.

 

Useful VF upgrade to show user “loading” picture while VF is loading

On the VF page:

<!-- workaround to show user “loading” picture while VF is loading --> <apex:form > <!-- start of VF performance workaround --> <apex:actionFunction name="ajaxSetClientLoaded" action="{!setClientLoaded}" immediate="true" rerender="DeferredLoad"/> <script type="text/javascript">var cached_onload = window.onload; window.onload = function() { ajaxSetClientLoaded(); if (cached_onload != null) cached_onload(); }</script> <!-- opening VF performance workaround panels --> <apex:outputPanel id="DeferredLoad"> <apex:outputPanel rendered="{!NOT(clientLoaded)}"><div align="center"><img src="{!$Resource.Loading}" /></div></apex:outputPanel> <apex:outputPanel rendered="{!clientLoaded}"> <!-- end of VF performance workaround --> ... your VF page code here ... <!-- closing VF performance workaround panels --> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page> 

 on the controller:

 

<apex:page standardcontroller="Account" extensions="IB_CCP_AccountIndustryCoverageController" boolean clientLoaded = false; public boolean getClientLoaded() { return clientLoaded; } public PageReference setClientLoaded() { clientLoaded = true; return null; } 

 

Note: $Resource.Loading is a “loading” image in GIF format saved in Static Resources

 

Regards,

  • October 26, 2011
  • Like
  • 0

 

Providing  Salesforce  (SFDC)  Consulting  and  Development service in Toronto & GTA since 2005.
Have advanced Salesforce/VisualForce implementations experience.
In-depth understanding of the capabilities and constraints of the SFDC CRM application coupled with good understanding of the business processes. Portfolio of projects from definition to deployment ensuring goals and deadlines are successfully met.
  • Configuration, Page layouts, Record Types, Custom Objects.
  • Reports, Dashboards, Apps, Validation/Assignment Rules.
  • Web-to-Lead Integration.
  • Workflow, Triggers and Approvals. Advanced Formulas. Instant Emails.
  • Security Profiles, Roles, Groups.
  • Building Applications with Force.com. Visualforce pages. Adding Business Logic with APEX.
  • Salesforce Object Search Language (SOSL), Salesforce Object Query Language (SOQL)
  • Eclipse and Force.com’ APIs. AppExchange and third party packages.
  • Database modeling. Data migration. Data ETL. Force.com Data Loader, etc.
Please contact me with your Salesforce project details.
_________________________________
Best regards,
Evgeny Soloho
Cell phone:     416 457 6947
E-Mail:         soloho@rogers.com

 

  • November 17, 2010
  • Like
  • 0

Hello All,

Just want to share my experience in creating Visualforce Email template where you want to display date and time in User timezone

 

***Overview
You are in MST time zone.
Let's say we have Date/Time field TaskDateTime__c and use it in Visualforce email template to show recipient the time in email.

<apex:outputText value="{0,date,EEEE, MMMM d, yyyy, HH:mm:ss}"><apex:param value="{!RelatedTo.TaskDateTime__c}" /></apex:outputText>

 

In email time will be converted and showed to GMT instead of EST.

 

The outputField (which convert time to user locale automatically) does not
work in Visualforce Email templates (not supported).

 

So how do I tell to display in Visualforce Email template time in User
timezone? For example MST?

 

***Implementation Details (worarounds)***

 

I found two workarounds:

 

Workaround 1: Use Controller class for the Component to use in template

In order to format the date in various TimeZone in Email Template, we can follow the steps:

1. First create a Controller class for the Component

Setup|App Setup|Develop|Apex Classes|New

Formatted_DateTime_Controller Class Code
----------------------------------------------------------

public class controller_formatted_datetime
{
public DateTime date_time { get; set; } //property that reads the datetime value from component attribute tag
public String defined_format { get; set;} //property that reads the string value from component attribute tag
public String getFormattedDatetime()
{
if (date_time == null) {return ''; }
else { if (defined_format == null) {
return date_time.format(); //return the full date/time in user's locale and time zone
}
else { return date_time.format(defined_format,'MST'); //Specify Time zone like IST,CST
}}}}

 

2. Create a Component

Setup|App Setup|Develop|Components

VF Component Code (Name: VFEmailTempComp)

<apex:component access="global" controller="controller_formatted_datetime">{!FormattedDatetime}
<apex:attribute assignTo="{!date_time}" description="The DateTime value to be rendered" name="date_time_value" type="DateTime"></apex:attribute>
<apex:attribute assignTo="{!defined_format}" description="The optional format to use for the DateTime value to be rendered" name="date_time_format" type="String"></apex:attribute>
</apex:component>

 

 

3. Create an Email Template and embed the component.

Setup|Administration Setup|Communication Templates|Email Templates

Email Template Code
---------------------------------

<messaging:emailTemplate subject="Testing DateTime Format" recipientType="Contact" >
<messaging:plainTextEmailBody >
Formatted: <c:VFEmailTempComp date_time_value="{!NOW()}" date_time_format="EEE MMM d kk:mm:ss z yyyy" />
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

It will display current time in MST timezone.


Workaround 2: Calculate difference in the apex:param value (for MST (-7) it will be 7/24=0.291666666

Date: <apex:outputText value="{0,date,EEEE, MMMM d, yyyy}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText>
Time: <apex:outputText value="{0,date,h:ma}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText> MST

  

  • August 28, 2012
  • Like
  • 4
Hi I have the following in a visual force template:
&nbsp;<b>Open Date:</b> &nbsp;<apex:outputText value="{0,date,EEEE, MMMMM dd, yyyy 'at' HH:mm:ss z}"><apex:param value="{!relatedto.BMCServiceDesk__openDateTime__c}" /></apex:outputText><br/>

However this is showing the time as GMT and not BST so is one hour behind.  How would I correct this?

Thanks in advance for any input

Sonya

Hi,

 

 I want to write a validation rule on  lead conversion.The condition will be like this:-

   i. Lead status is a picklist value.If lead status is  'NDA Signed' then it will convert the lead.If lead status is except the NDA Signed and I will click the convert button it will display an error meassage like 'lead conversion not possible'.

  • September 30, 2013
  • Like
  • 0

Hello All,

Just want to share my experience in creating Visualforce Email template where you want to display date and time in User timezone

 

***Overview
You are in MST time zone.
Let's say we have Date/Time field TaskDateTime__c and use it in Visualforce email template to show recipient the time in email.

<apex:outputText value="{0,date,EEEE, MMMM d, yyyy, HH:mm:ss}"><apex:param value="{!RelatedTo.TaskDateTime__c}" /></apex:outputText>

 

In email time will be converted and showed to GMT instead of EST.

 

The outputField (which convert time to user locale automatically) does not
work in Visualforce Email templates (not supported).

 

So how do I tell to display in Visualforce Email template time in User
timezone? For example MST?

 

***Implementation Details (worarounds)***

 

I found two workarounds:

 

Workaround 1: Use Controller class for the Component to use in template

In order to format the date in various TimeZone in Email Template, we can follow the steps:

1. First create a Controller class for the Component

Setup|App Setup|Develop|Apex Classes|New

Formatted_DateTime_Controller Class Code
----------------------------------------------------------

public class controller_formatted_datetime
{
public DateTime date_time { get; set; } //property that reads the datetime value from component attribute tag
public String defined_format { get; set;} //property that reads the string value from component attribute tag
public String getFormattedDatetime()
{
if (date_time == null) {return ''; }
else { if (defined_format == null) {
return date_time.format(); //return the full date/time in user's locale and time zone
}
else { return date_time.format(defined_format,'MST'); //Specify Time zone like IST,CST
}}}}

 

2. Create a Component

Setup|App Setup|Develop|Components

VF Component Code (Name: VFEmailTempComp)

<apex:component access="global" controller="controller_formatted_datetime">{!FormattedDatetime}
<apex:attribute assignTo="{!date_time}" description="The DateTime value to be rendered" name="date_time_value" type="DateTime"></apex:attribute>
<apex:attribute assignTo="{!defined_format}" description="The optional format to use for the DateTime value to be rendered" name="date_time_format" type="String"></apex:attribute>
</apex:component>

 

 

3. Create an Email Template and embed the component.

Setup|Administration Setup|Communication Templates|Email Templates

Email Template Code
---------------------------------

<messaging:emailTemplate subject="Testing DateTime Format" recipientType="Contact" >
<messaging:plainTextEmailBody >
Formatted: <c:VFEmailTempComp date_time_value="{!NOW()}" date_time_format="EEE MMM d kk:mm:ss z yyyy" />
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

It will display current time in MST timezone.


Workaround 2: Calculate difference in the apex:param value (for MST (-7) it will be 7/24=0.291666666

Date: <apex:outputText value="{0,date,EEEE, MMMM d, yyyy}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText>
Time: <apex:outputText value="{0,date,h:ma}"><apex:param value="{!RelatedTo.Scheduled_Clock_In__c - 0.291666666}" /></apex:outputText> MST

  

  • August 28, 2012
  • Like
  • 4

does anyone know of a way to make this work?  Currently the PDF populates with the HTML.

Hi,

 

I want to ask a question, is it possible to format the date field in Email template? Any suggestions would be great.

 

 

regards,

 

Edwin

Hey all,

 

So I am using some command buttons to execute some page redirects via page references, but I was wondering how I could specify the target for the new window. I know that outputLink has the target attribute, but I would like to stick with the default Salesforce style on the buttons and not have to recreate it myself. Right now I have resorted to using javascript because I can specify "_parent", but does anyone know how to accomplish this with a PageReference?

 

Thanks!

Hi, All-

 

I've actually posed this question to Salesforce Help Desk before, but they didn't quite give me the solution I was looking for.  I'm hoping one of you has a creative solution:

 

 

I'm looking for a way to make certain fields required before converting a lead but not required before saving that lead record.  Does anyone know a way to do this?

 

 

I'm thinking something can be done with a lead validation rule, but I haven't found a solution yet.

 

Thank you so much!

Hello,

 

I am trying to setup a date time stamp at the top of an email template so it would look something like this:

 

Jul 15 2009 10:01AM

 

I have tried using the {!Now()} function in my email template but it comes out as GMT which is a few hours ahead of us here in CST.  

 

Could anyone tell me a better way to add today's date to the top of an email?  I've been all through the discussion boards and Technical Library and can't seem to find it.  If I missed an example or discription a link to that would be great too.

 

Thanks in advance,

Marc Petersen

I have an apex command button as below calling a custom controller method

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="this.disabled=true;"/>

 

The method saves the item and navigate to another page. It is not a partial page update call.

 

I would like to disable button after the first click. I tried using onclick and calling a javascript to set the disabled status as true. When I use onclick even to make the javascript call, the button becomes disabled, but the save method on the controller is not being called.

 

I changed the button onclick event  to just alert 'hi' as below and it works. It alerts and then also makes the method call

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="alert('hi');"/> 

 

But when I added the code to disable the button too as shown below, it stops calling the controller method.

 

<apex:commandButton value="Add Item(s)" id="addItem" action="{!addItems}" onclick="alert('hi');this.disabled=true;"/>

 

Is there a different way to solve this?

Message Edited by DCS on 05-07-2009 02:03 PM
  • May 07, 2009
  • Like
  • 0

Here is my brief skill-set: 

 

    * 3 years experience for salesforce, 6+ years for software development.
    * Apex coding (Triggers, testMethods, Webservices)
    * Visual Force
    * S-Controls
    * Web API, .Net, C#, ASP.NET, Javascript
    * Workflow rules
    * Deployment

    * and SFDC customization

 

For further information please email me at eperla@live.ca. 

 

ePerla

Message Edited by yoyo on 02-20-2009 08:12 AM
Message Edited by yoyo on 02-20-2009 08:12 AM
  • February 20, 2009
  • Like
  • 0
I have created a few custom components for the home page and was wondering if there is an easy way to hide the name of the component when it is displayed?  It appears that SFDC takes the name of the custom component and puts it in a h2 tag. 

I'm thinking I can write some JavaScript to locate the specific h2 tags I want to hide (clearing out the innerHTML) and embed that in the "Messages and Alerts" component, but I wanted to see if there was a better way to accomplish this.  Any suggestions?

I am testing a number of insert routines for a custom object using the APIs.  I noticed in the salesforce.com setup area, there does not appear to be a way to mass delete rows in a custom object.

Is there a recommended way to mass delete rows from a custom object?  I have been unable to find the right message in the various posts.

I want to delete the rows I added so I can retest as needed.  Do I need to create a separate program to select the rows by create date and delete each one.

Thanks

Mike Schumacher