May 24th, 2013
141 : User Wants to set the starting day in Calendar as “Monday” instead of “Sunday”. How to get it done?
Ans : Change the user locale to “English ( United Kingdom ) ” in Personal information or User record.
142 : Why CSS is not working in PDF created by Visualforce ?
Ans : In Many cases, i have observed problems faced by my colleagues and complaining that CSS is not working when they try to render any Visualforce page as “PDF”. Same Question is asked many times in Interviews also. Basically there are two ways:
- Use “apex:stylesheet” tag to import external CSS file
- Wrap “Style” tag inside “Head” tag in Visualforce
143 : How to get Ip Address of User in Apex?
String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url.
Thanks to TechNrd for this tips.
May 17th, 2013
I have seen many customers in need to have Dynamic Filter. In Absence of Dynamic filter, many times we end up with creating multiple reports with same format and different condition.
Many time, we need something like get all cases related to Parent Account of Opportunity. We can simply create a report for Case and add Condition for Account Name. Using Some Custom Link, we can always Change Account Name and same report can be used many times.
While navigating to community i found very interesting and useful information regarding dynamic Filter in Reports.I thought that Dynamic Filters inside Salesforce is not possible but It is Possible.
May 6th, 2013
In Many situation, I needed a Mass Delete Kind of button. Where, i can select records in ListView and simply click “Delete” button.
In this example, we will create a simple List View button and add on “Search Layout” of that object.
Salesforce Mass Delete Button – List View
So, create a new Custom Button with following property:
- Display Type : List Button
and use below Source code:
May 6th, 2013
In many cases, I have seen customer struggling with “Standard Mail Merge” functionality. I have suggested them to either use “Drawloop” or “Conga Composer” however these applications are paid.
Before going ahead let’s see the drawbacks of “Standard Mail Merge”:
- It runs on Client side and needs ActiveX Control
- It needs Internet Explorer
- It does not work with Office 2010, it works only for Office 2003 and 2007
- Windows 7 is not supported and causes unexpected error many times. It supports Windows XP and Windows Vista only
The solutions to all above problem is “Extended Mail Merge (XMM)” template which is free and native Salesforce solution.
Following are the advantages of “Extended Mail Merge (XMM)”:
- It runs on server side and does not require installation of any ActiveX Control
- It runs on almost al major browsers including firefox, Chrome
- It supportes Office 2007 as well as Office 2010 (document must be saved in a 97-2003 DOC format)
- We can save output into “Document” tab
- XMM can send final word document in email itself
NOTE: Mail Merge & Extended Mail Merge uses same templates: “Setup | Communications Templates | Mail Merge Templates”
There are few limitations in XMM also like:
- At a time, it can merge only 1000 records.
- Template size cannot exceed 1MB of size.
- It will access only those fields for which current user have access, it respects Field level security (FLS)
How to enable “Extended Mail Merge (XMM)” ?
We have to contact Salesforce to enable this feature in our Salesforce Organization.
May 3rd, 2013
One of the disadvantages comes up with Custom Page or Overriding New or Edit button with Visualforce page is its “Maintenance”, if New Filed is Added or needed to remove field we have to modify our code every time.
However, Thanks to Salesforce that we have “Field Set”.
With the Help of “Dynamic Visualforce Binding” and “Field Set” we can create effective Visualforce pages with ability to change Fields and its Sequence any time without modifying any code.
Let’s start with using Field set in Salesforce.
Step 1: Creating Field Set
First we need to create a field set. For this article, I am using custom object named “Question__c”.
We have to navigate to setting page of that object and then “Field Sets”. Create a new Field Set and add required field in Sequence as displayed in below image.
Create Field Set in Salesforce
Assume that field set name is “Add_Question”.
March 3rd, 2013
This tutorial is regarding editing of static resources inside eclipse itself. Normally if we want to edit any file inside zip, first we have to extract and edit the file, zip it again and reload into static resource. To save this round trips and time consuming process I found one very useful eclipse plugin called as “Eclipse Zip Editor”. Although it’s very small tweak however it will save your lot of time and unnecessary trip to Salesforce and Zip tool.
You can download this editor from location “http://sourceforge.net/projects/zipeditor/“
Static Resource in Eclipse Before Plugin
March 3rd, 2013
Hello Readers, in this article we will see step by step procedure to deploy your first (Hello World) program in Heroku. There are two ways, first going through series of Commands of “Heroku” and “GIT” and other simple and smart way is to use Eclipse Capability with Heroku. To make things easier we will go by second method.
Installation and Set up:
First we will need to Install Heroku Plugin in Eclipse. To install it, Navigate to “Help | Install New Software” and click on “Add” button.
Give any name in website like “Heroku Plugin” and enter this URL in Location https://eclipse-plugin.herokuapp.com/install and click on “Ok” and Finish Installation. It will install the Heroku Plugin required to start your first Plugin.
Next step is setting up your Credentials for Heroku :
Navigate to “Window | Preferences | Heroku”, Here either enter your UserName and Password of Heroku Account and click on “Login” or enter you API key, which you can find by logging into your Heroku Account.
Setting up Credentials for Heroku in Eclipse
February 28th, 2013
131. What will happen if you try to update record in After Trigger Context?
Ans : You will get an error saying “record is Read only”.
132. Let’s say we have to update the same record in After Trigger context. Is there any way or workaround?
Ans : If we create a new instance of an SObject in the Apex Trigger in memory using the Id of the newly created record as provided in the After Trigger context, we can perform an Update DML statement and not get a read only error. This is because in Apex, the SObject is seen as a new reference (even though the records have the same SFDC ID) and therefore is eligible for DML operations. The below snippet of code illustrated this working and not working.
List<Contact> originals = new List<Contact>();
if(mirrorResultMap.values().size() > 0)
for(Contact origContact : contactRecs.values())
Contact mirrorContact = mirrorResultMap.get(origContact.Id);
//origContact.Linked_Contact__c = mirrorContact.Id; //Link the Original Record tot he Mirror Record WILL FAIL
Contact origContactUpdate = new Contact(Id=origContact.Id, Linked_Contact__c = mirrorContact.Id); //This will WORK
//update contactRecs.values(); //Update the Records -> THIS WILL FAIL AS ITS ORIGINAL RECORDS IN MEMORY
Credit goes to Cory Cowgill for this Blog Entry.
133 . When loading data into date fields such as Opportunity Close Date using the Data Loader, the date displayed in the application is sometimes one day earlier than the date in the file. What may be the reason and solution ?
The reason for this is that fields such as Close Date are actually date/time fields. When a date is loaded without specifying the time, the time is defaulted to 00:00 – midnight. When another user is in a time zone which is behind the current user’s time zone, the date will show on the previous day. For example:
20 August 2008 00:00 in Paris is 19 August 2008 23:00 in London
Similar issues can arise when daylight savings time begins or ends.
Two simple solutions to this are:
1) Specify a time as well as a date when loading dates using the Data Loader.
2) Switch your PC’s time zone to Hawaiian time before starting up the Data Loader.
February 27th, 2013
This is very short tips to resolve the errors “ArtifactTransferException: Could not transfer artifact” that may occur in Maven project in Eclipse.
Steps to resolve:
- Open folder by running this text (without Quotes) in Search Explorer of Window “%USERPROFILE%\.m2″.
- After running above command, “m2″ folder of maven will open. Now search for file (without Quotes) “*.lastUpdated”.
- In this step, delete all the files found by running Step 2.
- Now go to Eclipse project and select “Maven | Update Dependency” or “Maven | Update Project”.
By now, your issue will be resolved.
Happy Coding !!!
February 24th, 2013
In Customizable Forecast, we can add the Quota for user by navigating to User Page and going to Quota related list However in Collaborative Forecasting aka Forecast 3 the only way is using Data Loader.
1. Log-in to the Data Loader and use the Insert function.
2. Click “Show all Salesforce objects and select “Forecasting Quota (ForecastingQuota)”.
Note: Only Data Loader version 25 and above can be used for importing Quotas in Collaborative Forecasting
3. Select the import csv file and click Next (click OK in the pop-up that shows the number of records detected in the file).
Note: The import csv file should contain the following columns:
- Currency ISO Code
- Quota Amount
- Owner ID
- Quota Month (Start Date, In Date Format)
Import Quota Using DataLoader for Forecast 3