Ye Meri Life Hai - Chirag Mehta

Be Good & Do Good!

Page 6 of 133

How to format a date in VisualForce?

Problem Statement
In Salesforce, if I’m binding a date into a VisualForce page, how do I apply custom formatting to it?

Example:

<apex :page standardController=”Contact”>
</apex><apex :pageBlock title=”Test”>
<p>{!contact.Birthdate}</p>
</apex>
<apex :detail relatedList=”false” />

This will output a date in the default format:

Thu Jul 01 09:10:23 GMT 2009

How do I get it (for example) into dd/mm/yyyy format, like this:

01/07/2009

Solution

<apex :outputText value=”{0,date,MM’/’dd’/’yyyy}”>
<apex :param value=”{!contact.Birthdate}” />
</apex>

Solution

Source : StackOverflow.com

Salesforce – Restrict emails on new case, task, password reset …

The Salesforce.com user interface allows you to specify whether or not to send an email when the following events occur:

Creation of a new case or task
Creation of a case comment
Conversion of a case email to a contact
New user email notification
Password reset

In Apex scripts saved against API version 15.0 or later, the Database.DMLOptions emailHeader method enables you to specify additional information regarding the email that gets sent when one of the events occurs because of the script’s execution.

The following are the options that can be set with the emailHeader method:

  1. triggerAutoResponseEmail : Indicates whether to trigger auto-response rules (true) or not (false), for leads and cases. In the Salesforce.com user interface, this email can be automatically triggered by a number of events, for example creating a case or resetting a user password. If this value is set to true, when a case is created, if there is an email address for the contact specified in ContactID, the email is sent to that address. If not, the email is sent to the address specified in SuppliedEmail.
  2. triggerOtherEmail : Indicates whether to trigger email outside the organization (true) or not (false). In the Salesforce.com user interface, this email can be automatically triggered by creating, editing,or deleting a contact for a case.
  3. triggerUserEmail : Indicates whether to trigger email that is sent to users in the organization (true) or not (false). In the Salesforce.com user interface, this email can be automatically triggered by a number of events; resetting a password, creating a new user, adding comments to a case, or creating or modifying a task.

In the following example, the triggerAutoResponseEmail option is specified:

Account a = new Account(name=’Acme Plumbing’);
insert a;
Contact c = new Contact(email=’jplumber@salesforce.com’, firstname=’Joe’,lastname=’Plumber’,accountid=a.id);
insert c;
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerAutoResponseEmail = true;
Case ca = new Case(subject=’Plumbing Problems’, contactid=c.id);
database.insert(ca, dlo);

Visualforce – Adding History related list to Tabbed Account

Problem Statement
Has anyone been able to generate the “account history” tab in visualforce page? If i try using “Histories” in <apex:relatedList>, I get error msg saying it is not valid child relation name..

Solution1
This works for me to add a link to the account field history:

<apex:tab label=”Field History” name=”Field History” id=”fieldhistory”>
<apex:outputLink value=”https://na1.salesforce.com/_ui/common/history/ui/EntityHistoryFilterPage?id={!account.id}”>
click to view field history
</apex:outputLink>
</apex:tab>

Not optimum as user has to click the link but you dont need to do a lot of work.

Solution2
I also figured out how to access the Account History data. It is NOT a related list. Instead, use the code <apex:dataTable> to pull from the account.histories table. Below is rough code that will pull the Account History into a separate tab. The HTML formating is not very clean, but the data query works!:

<apex:tab label=”Field History” name=”Account History” id=”fieldhistory” >
<apex:dataTable value=”{!account.histories}” var=”accounthistory” id=”HistTable” rowClasses=”odd,even”
styleClass=”tableClass” cellspacing=”15″ width=”80%”>
<apex:facet name=”caption”></apex:facet>
<apex:facet name=”header”>Field History</apex:facet>
<apex:facet name=”footer”></apex:facet>
<apex:column>
<apex:facet name=”header”>Edit Date</apex:facet>
<apex:facet name=”footer”></apex:facet>
<apex:outputText value=”{0,date,MM/dd/yyyy HH:mm }”>
<apex:param value=”{!accounthistory.createddate}” />
</apex:outputText>
</apex:column>
<apex:column>
<apex:facet name=”header”>Field</apex:facet>
<apex:facet name=”footer”></apex:facet>
<b> <apex:outputText value=”{!accounthistory.field}”/></b>
</apex:column>
<apex:column>
<apex:facet name=”header”>Edited By</apex:facet>
<apex:facet name=”footer”></apex:facet>
<apex:outputText value=”{!accounthistory.createdby.name}”/>
</apex:column>
<apex:column>
<apex:facet name=”header”>Old Value</apex:facet>
<apex:facet name=”footer”></apex:facet>
<apex:outputText value=”{!accounthistory.oldvalue}”/>
</apex:column>
<apex:column>
<apex:facet name=”header”>New Value</apex:facet>
<apex:facet name=”footer”></apex:facet>
<apex:outputText value=”{!accounthistory.newvalue}”/>
</apex:column>
</apex:dataTable>
</apex:tab>

Source : Salesforce Community

URL to export(download) Salesforce Report

Problem Statement
It may be possible that sometime you need to code or provide a link to directly download a report.

Solution
In order to directly export a report, navigate to following URL. This URL request will prompt you with open/save dialog to export the report.

ExportReport

Here,

https://na1.salesforce.com is Salesforce hostname on which the org is hosted
00O30000001Y9ll is report Salesforce ID
export=1 is the parameter required to request system for direct download of report

Also note that,

Salesforce out of box feature does allow exporting of report, but its 3 step process
Navigate to report
Click Export Details
Click Export

Salesforce – VMware to announce “VMForce”

What’s the story behind “Salesforce – VMware to announce VMForce”. Salesforce is advertising loudly something as follows …

Join industry leaders Marc Benioff, chairman & CEO of salesforce.com, and Paul Maritz, president & CEO of VMware, for a live Webcast where they will make an exciting joint product announcement on the future of cloudcomputing.

VMforce is ComingMarc - Paul

Date: April 27, 2010
Time: 10:30 a.m. PDT
Location: www.vmforce.com

We got only thing to do is to wait and watch ..
What is VMforce all about and to what level will it transform the CLOUD world …

About Salesforce & VMware
Logos
Salesforce.com is the world’s biggest provider of software that is delivered via the Web.
VMware is the top maker of virtualization programs that allow companies to boost the efficiency of computer hardware by running multiple virtual machines on a single piece of equipment.

How to Deep Link to a Specific Point in a YouTube Video

There are hundreds of videos on YouTube which contain valuable best practice content. To help surface the golden nuggets here are three ways to deep link to specific places within the video.

1. Create a link to a specific part in a YouTube video

If you want to link to a specific part of a video on YouTube, you can. For example,
http://www.youtube.com/watch?v=PjDw3azfZWI#t=31m08s

Notice the “#t=31m08s” on the end of the url? That link will take you 31 minutes and 8 seconds into that video. Linking to a particular minute and second can be really helpful — for example, that link takes you straight to where someone asks Eric Schmidt a question about Twitter. From there, you can listen to his answer, where he says (among other things): “We’re in favor of all of these new communications mechanisms. ….”

2. Start an embedded YouTube at a certain timestamp

To do it on an embedded video, use the “start” parameter. Note that start takes seconds as a parameter, not minutes and seconds. For example, to start an embedded video 31 minutes and 8 seconds into a video, 31*60+8 = 1868 seconds, so you would use this code:
<object width=”640″ height=”385″><param name=”movie” value=”http://www.youtube.com/
v/PjDw3azfZWI&hl=en_US&start=1868″></param><param name=
“allowscriptaccess” value=”always”></param><embed src=”http://www.youtube.com
/v/PjDw3azfZWI&hl=en_US&start=1868″ type=”application/x-shockwave-flash” allowscriptaccess=”always” width=”640″ height=”385″></embed><
/object>

3. Use annotations to create links within your videos

Read more on how to create and use annotations at http://www.youtube.com/watch?v=CDsLSFKwgFI

How to export data to CSV file/text file using Apex

Problem Statement
I want to export list of object into CSV file using Apex

Solution

<apex:page controller="csvController" cache="true" 
contentType="text/csv#filename.csv" language="en-US">
"Col A","Col B","Col C","Col D"
<apex:repeat value="{!myList}" var="a">
"{!a.ColA}","{!a.ColB}","{!a.ColC}","{!a.ColD}"
</apex:repeat>
</apex:page>

Please note that

  • With the #filename.csv, it prompts the user to save/open the file. Otherwise, it loads into the browser as html
  • You’ll also have to format the VF page as a clean csv text file, that means no pageblocktables or anything that might insert html formatting.
  • if customer want to export data object to text file use contentType=”text/plain”

Source : Salesforce Community

Indian company to create call center jobs in the US

There is one word used over and over again in India to describe JustDial

http://tctechcrunch.files.wordpress.com/2010/03/mani_just_dial_01.jpg?w=300&h=199

The idea is simple: You call up and within the first ring a real person picks up the phone, you ask them for any business listing – in any category – and within 45 seconds they email or text you the information or, if you prefer, connect the call.

The company will end its fiscal year at the end of March with some $32 million in revenues having answered 72 million calls in the last year. That call volume is increasing by 40%, so the company expects to break 100 million calls in the next year. In a country where nearly everyone has a mobile phone but just 50 million people have Internet access, JustDial is essentially Google and 411 rolled together.

The move is a direct volley at a service like GOOG-411, which has opted to do the same thing, but using voice recognition software. But Founder and CEO V.S.S. Mani (pictured above, in one of his call centers) is betting that nothing beats a human voice with a quick answer.

For now, JustDial’s US operations will be handled out of India, where the company employs some 4,000 people but, in a twist to the direction most call center jobs are flowing, Mani plans to hire up big in the US—up to 1,000 people mostly in under-employed, rural areas. “We need a big presence in the US very soon,” Mani says. That right– an Indian company will be creating call center jobs in the US

Smart GMail – Did you mean to attach files?

Today one of my friend noted a really unnoticed yet creative behavior of GMail. He tried to send an email with body containing “please find attached ….” and he clicked send, GMail instead of sending that email popped-up a message

Did you mean to attach files? You wrote “find attached” in your message, but there are no files attached. Send anyway?

This alerted him that he missed on attaching the files.

Isn’t that really smart and creative thinking! Though a minute thing, but such small things of intelligence makes GMail (Google) an innovator at email services.

Cheers Google!

Ability to create alias for field labels across Profiles

Problem Statement
We have users in multiple countries and different vernacular for the same entity. Is it possible to create an alias for a record type that displays for users with a specific profile so we can use the same record types and records, yet have the customization between different countries? It’s almost like using translations, but it’s all within the English language.

Example: Record Type “Municipality” vs. “Local Authority” for same records
Everyday users see Municipality
UK users see Local Authority

Possible Solutions

Terrence: Look at the new Translation Workbench feature. The Translation Workbench allows you to create translations for the customizations you’ve made to your Salesforce.com organization. Everything from custom picklist values to custom fields can be translated so your global users can use all of Salesforce.com in their language.
Go to Setup | Admin Setup | Translation Workbench.

Tom: You may also be able to utilize the Tags function. Setup / Customize / Tags.
This would enable each user to “tag” the field with the name that they are comfortable with. That would help them with the different names in different areas.

Paul: Unfortunately I don’t see how either of these options will work. The translation workbench does not specify English and English (UK) as two different languages, and I imagine if you set someone’s language to another language like Spanish then all of the standard tabs and fields are in that language. I don’t see how to change the translations for standard tabs and fields in the workbench.

The tag feature is for tagging records, it does not allow you to tag fields, and it has to be done for each record.

I think you have two options:

One option is just to make all the fields have both names, like State/Province. In your example just rename the field Municipality/Local Authority. You can even rename standard fields under Setup > Customize > Tab Names and Labels. RECOMMENDED Solution

Your other option is to create two fields for each one that you want to modify. Setup a workflow rule or trigger that automatically updates the matching field whenever it’s entered. Then create two different page layouts that are used based on the user’s profile (so UK users would have to have a different profile from US users).

Depending on the number of fields that you’re talking about, the second one could get really complicated.

Discussion @ Salesforce Linked In

« Older posts Newer posts »