Monday, December 30, 2013

Search Page in Visualforce-Simplified

Here is a simple example how to build a simple Visualforce search page. When I started learning Visualforce I thought building a search page is too complex, but it's not true. We can modify the wrapper class example which I posted earlier to achieve this. Nothing much to dig deeper into the code. The code is very simple just passing the get set parameters from a text field to the controller query using the 'LIKE'clause. Here is the controller for it to give you a clear picture.

 public with sharing class accsearchcontroller {  
   public list <account> acc {get;set;}  
   public string searchstring {get;set;}  
   public accsearchcontroller(ApexPages.StandardController controller) {  
   }  
   public void search(){  
     string searchquery='select name,id from account where name like \'%'+searchstring+'%\' Limit 20';  
     acc= Database.query(searchquery);  
   }  
   public void clear(){  
   acc.clear();  
   }  
 }  

    let's see what I have done here. I have created a string variable searchstring and used the variable in the LIKE query. This search string gets the input from the text box in the visualforce page where user will enter the data and again passes the query string variable inside the database.query() method. If you look at the visual force page code

 <apex:page standardController="account" extensions="accsearchcontroller">  
  <apex:form >  
 <apex:inputText value="{!searchstring}" label="Input"/>   
  <apex:commandButton value="Search records" action="{!search}"/>  
  <apex:commandButton value="Clear records" action="{!search}"/>  
   <apex:pageBlock title="Search Result">  
    <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column >  
      <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
  </apex:form>  
 </apex:page>  



Here is the button action method "Search" which returns the list of records. It's simple isn't it?

Monday, November 18, 2013

CRM market trends



What is a customer relationship management software?
CRM or customer relationship management software is an organization wide business strategy which is designed to reduce cost and increase operational efficiency, Customer satisfaction, customer loyalty, and advocacy. The content of the report has latest facts and figures about current market trends of the CRM industry. In particular with cloud based CRM systems especially  Salesforce.com CRM.

Scope of the article:
·         Market size and share information about Indian CRM market.
·         Major areas of focus including sales automation, Service automation, marketing automation, Collaborative tools and flexibility with other Technologies which includes web services.

·         Key players salesforce.com, oracle Seibel, Microsoft dynamics, SAP AG

Image Courtesy:Forbes

International CRM market share
The Tier 1 enterprise software market is dominated by Oracle Siebel, SAP CRM and Salesforce. SAP and Oracle were early entrants to the India market in 1990s. Oracle's Siebel product and Amdocs have largely penetrated the India software landscape along vertical markets, while SAP CRM has been more broadly adopted in largest part riding on the coattails of SAP's highly successful enterprise resource planning (ERP) software suite. While Oracle CRM and PeopleSoft are gradually being phased out on a global basis, these legacy solutions may operate longer in India than other global regions as many local companies have less desire to upgrade than their international counterparts.
The on demand model for CRM systems is increasing rapidly CRM vendors like Salesforce.com, Microsoft dynamics, ZOHO etc.., has a strong cloud presence. They came up with the revolutionary software as a service or SAAS model. Which will help customers to pay for what they actually use.
Even though oracle and SAP CRM and SAP AG have strong presence in Indian CRM industry the main dis advantage is that these softwares are on premise soft wares. They are very expensive to maintain and operate and their scalability is less. So the new trends of the industry started to shift towards SAAS model which is completely cloud based.

Software as a Service (SaaS) in India:
Software-as-a-service (SaaS) is poised to grow seven times faster than on premises application software for the next three years, reports research firm Gartner. By 2011, a quarter of new business software is projected to be SaaS.
SaaS penetration in India is somewhat inconsistent in terms of market share however much more constant in terms of growth projections. One research study estimates the India Software as a Service (SaaS) market at USD $65M in 2010 and projected to grow in excess of 20% annually. In another research report, the market for on-demand solutions in India is over USD $32 million in 2009 and expected to grow at a CAGR of 50% to 60% for the next few years. Notwithstanding the task of achieving consistent estimates in a complex region, SaaS is forecast to be the preferred mode for new CRM implementations in the coming years especially for SMBs.

Salesforce and Multitenancy Architecture (SaaS Architecture):
Imagine an apartment with shared resources which has common gas line , Cable tv and water resources and all the occupants of the house have the flexibility to pay for what they actually use. This is how salesforce work.
Multi-tenancy is an architecture in which a single instance of a software application serves multiple customers. Each customer is called a tenant. Tenants may be given the ability to customize some parts of the application, such as color of the user interface ( UI) or business rules, but they cannot customize the application's code.
Multi-tenancy can be economical because software development and maintenance costs are shared. It can be contrasted with single-tenancy, an architecture in which each customer has their own software instance and may be given access to code. With a multi-tenancy architecture, the provider only has to make updates once. With a single-tenancy architecture, the provider has to touch multiple instances of the software in order to make updates.
In cloud computing, the meaning of multi-tenancy architecture has broadened because of new service models that take advantage of virtualization and remote access. A software-as-a-service 
(SaaS) provider, for example, can run one instance of its application on one instance of a database and provide web access to multiple customers. In such a scenario, each tenant's data is isolated and remains invisible to other tenants.

Who am I?
                I am Nirmal Christopher, Currently working as  a salesforce technical consultant in Chennai, India. I have 1.4 years of experience in Salesforce CRM which includes skills in the areas such as Support, customization, Administration, Application development, data migrations, Training end users, Non profits for salesforce etc.
I have implemented CRM solutions for 8 customers who plays big role in variety of industries like heath care, IT, Consumer Electronics , Manufacturing, NGO’s etc…

Any questions reach me at +919952851577
Email: Nirmal.christopher@gmail.com


Wednesday, October 16, 2013

Wrapper class a Beginner's walkthrough.








 Have been out for quite some time it’s been a very long time. Since I posted programming content a long time ago, I’m back with some delicious content. Wrapper classes Wrapper generally refers to a type of packaging a content. When I tried to pull the data from unrelated different object many suggested me to use the concept of wrapper classes. I did some case studies about inner classes in Java back in my college really long time ago and in the middle I changed my profession and again back as a programmer. So everything started flying above my head. No simple content I found for creating wrapper classes so at that point I decided to create a proper blog which will help beginners to grasp the usage of this technique. Here we are gonna wrap data in to a single programming unit, Hence this type of programming technique is called wrapper classes.

What is a wrapper class?
In Salesforce we have the concept of collections where different data types like string, SObjects are stored, Iterated and used as per the business logic. So these primitive data types are something standard like these standard data types we can use the properties of custom defined data types using the concept of wrapper classes. Hence we can query do some business logic in the collection elements with custom data type.

When to use Wrapper classes?
As per my experience we can use wrapper class collection elements. If we need to iterate through a data which is stored in a multiple Sobjects and datatypes. For example I wanted to do a pagination where have to display a list of records next to a check box, so that user can choose the check box which means the user has selected a particular record. In this case we are gonna add the Boolean value of the check box and record id in to a list with custom data type.

Structure of wrapper classes:

Forget pagination I’m gonna demonstrate a simple example of displaying data from unrelated multiple objects so the article works like a primer for the concept of wrapper classes. below is the simple interface i gonna create for the demo.if I press the fetch data button the page is gonna display the data from multiple objects which is not related with each other.  Something like this






 Here fetch data and clear data are the buttons which will work as the switches for the mechanism to fire.
here is the controller code to achieve this

Controller Code:

 
//////<<<<<<<<<<<<<<>>>>>>>>>>>>>>////////
/////Created by Nirmal Christopher////////
//////<<<<<<<<<<<<<<>>>>>>>>>>>>>>////////
public class sun_example {  
 public list<wrapperclass> disp_list{get;set;}  
 //Declare a wrapper class  
      public class wrapperclass{  
      public VF_practice_pages__c vf1{get;set;}  
     //custom wrapper datatype  
      public string name{get;set;}  
      public string ssn_number{get;set;}  
      public string name1{get;set;}  
      public string productName{get;set;}  
    }   
   public sun_example() {  
 //define constructor to instantiate the wrapper data type  
   disp_list=new List<wrapperclass>();  
   }  
   //Method for processing logic  
   public void generate_data(){  
 //querying different objects accounts, VF_practice_pages__c, product2 which is not related at all  
     List<account>acc=[select id,Name from account where createddate!=null order by name limit 5];  
     list<VF_practice_pages__c>vfpp=[select id,name,name1__c,SSN_Number__c from VF_practice_pages__c where createddate!=null order by name limit 5 ];  
     list<product2>proList= [SELECT IsActive,Name FROM Product2 WHERE IsActive = true order by name limit 5 ];  
 //Iterate through each list to extract the values and add it to the custom wrapper data type  
       for(account accs:acc){  
         for(integer i=0;i<vfpp.size();i++){  
           for(integer k=0;k<proList.size();k++){  
 //Instantiating the wrapper SObject   
           wrapperclass w=new wrapperclass();  
 //Assigning the wrapper variables from the SObject Fields in the database.  
           w.ssn_number=vfpp[i].SSN_Number__c ;  
           w.productName=proList[k].name;  
           w.name1=vfpp[i].name1__c;  
 //Adding everthing to the List  
           disp_list.add(w);  
           w.name=accs.name;  
      disp_list.add(w);  
         }  
       }  
     }  
   }  
   public void cancel_data(){  
     disp_list.clear();  
 }  
 }  

And this is the VF page. Inside Apex repeat tag I have added the wrapper list “disp_list” Which will have the wrapped up data of all the s objects used in the controller.

 <apex:page controller="sun_example" showHeader="false" sidebar="false" >  
  <apex:form >  
  <apex:pageBlock >  
 <apex:pageBlockButtons location="both">   
 <apex:commandButton action="{!generate_data}" value="Fetch Data"/>   
 <apex:commandButton action="{!cancel_data}" value="Clear List"/>   
 </apex:pageBlockButtons>  
  <apex:pageBlockSection >  
   <table>  
  <tr>  
    </tr>  
   <tr>  
  <td><b>Account Name</b></td><td><b>Custom object field</b></td><td><b>custom object field</b></td><td><b>product name</b></td></tr>  
  <apex:repeat value="{!disp_list}" var="ttt">  
  <tr><td>{!ttt.name}</td>  
  <td>{!ttt.name1}</td>  
  <td>{!ttt.ssn_number}</td>  
  <td>{!ttt.productName}</td>  
 </tr>  
 </apex:repeat>  
  </table>  
  </apex:pageBlockSection>  
  </apex:pageBlock>  
  </apex:form>  
 </apex:page>  

Thus the value inside a wrapper list is accessed using the alias name in the list “ttt”. Feel free to write to me if any questions.


Thursday, October 3, 2013

Winter 14 features really exciting


Abstract
We will focus on various enhancements available in Winter 14 pre release. The key features I have highlighted in winter 14 release are listed below.

Enhanced Look ups

As a starter let’s drill down a bit deeper with the new winter 14 upgrade feature. We don’t have to worry about the clumsy search box any more. Welcome to Winter 14 era of look ups unlike its predecessor new version of look ups allows you to search for records with different items or fields rather than using the name as the search criteria.  For instance you can if we are using the look up field built on accounts to search for contact we can include the search key words as E-mail or First Name. For the list of searchable fields by objects kindly refer the link below.
Note: This option is currently available for only accounts, contacts, and custom objects. It’s not available
For the user object.

Please make sure you have enabled the enhanced look ups in the search settings in your organization set up.

Chatter upgrades
                Winter 14 has its new set of features in its chatter settings in search functionality. Which includes enhanced global search settings in the mobile device’s native app and one more interesting feature compact Layouts

Compact layouts overview:
In Chatter mobiles compact layouts display a records key page and designed for viewing record pages in mobile devices.
Except these fields compact layouts are available for all other fields in chatter mobiles.

o    
o   text area
o   long text area
o   rich text area
o   multi-select picklist

In other words compact layouts are the page layouts like standard sales force page but with additional features to display items on it and also Salesforce mobile is now re named as Salesforce Classic.
                In addition to these features Archived chatter groups allow users to focus on the users who have more activities and feeds. With all these features chatter is now up-graded and now more efficient.

Social Accounts and Contacts
In Salesforce winter 14 edition a use can see his leads and contact’s social images even if they are not offline and also in the list page they can see the available social accounts for all the records.
Refer this image below.

 
Additional enhancements in Data.com

State and country picklists:
State and country pick lists are now available in Salesforce. It allows the users to select the standard valued for states and countries for the available standard lists. These pick list are configured based on ISO-3166 making them compatible with other application as well. This feature can now be configured under the data management settings in the set up menu.

Workflow rules for user objects:
                The most striking upgrade feature available in the winter 14 release is the ability to create work flows in user object. Now administrators will have the ability to create work flow actions and rules for the user object. This reduces lot of time In creating the custom logic using Apex.

Other upgrades to consider:
Apart from these upgrades there are so many other minor and upgrades in the click and point arena and also few important upgrades ion apex and visual force as well. They have also included few tags and attributes which are the pilot components like <apex:input tag> and few attributes for HTML 5 components and also few methods in the database object such as database.merge(), database.getdeleted() and database.getupdated().



So many useful features in Winter 14 release. I have dug only few key features in this blog and hope the uses of the other upgrades will also play a crucial part in the design and development area.

Wednesday, June 26, 2013

Deployment in Salesforce

Created By: Nirmal Christopher
                      SFDC  Technical consultant

Change Sets and Deployment Production

What is a Change set???

A change set is a means by which one organization can send customizations to another organization.
  • An outbound change set is a change set created in the organization you are logged into and want to send to another organization.
  • An inbound change set is a change set that has been sent from another organization to the organization you are logged into.
  • Change sets can only contain modifications you can make through the setup menu.
  • Change sets may contain customizations to existing components or new components, but can't be used to delete or rename components.
Let me walk you through the steps involved in deploying components from sandbox to production

Step #1:
The first step involved in deployment from sandbox to production is to make sure proper deployment connections has been made in the sandbox instance and production instance.  
  Navigate as follows
User Menu->Setup->App Setup->Deploy->Deployment Connections. Please refer the screen shot below for further clarification.
Here you can see the list of connections available for  sandbox production seems the connection to production environment is already active.



·         A deployment connection is automatically created between all related organizations whenever a sandbox is created.
·         Each organization must be authorized to send and receive change sets.
·         The deployment connection list shows which organizations can upload changes to this organization, and which organizations allow this organization to upload changes to them.

Step #2

The step 2 would be creating outbound change set and its components in sandbox.
Please make sure that Allow inbound changes option is checked true in Production org in deployment connections option else you will get and error message if you try to upload the components into the production org. Refer the screen shot below.

You can navigate the outbound change set component as follows User Menu->Setup->App Setup->Deploy->Out Bound changes set.

Click New to create a new outbound change set. It will navigate to a screen where you can see a Name field(Required field) and description field. Fill the fields and click Save.

It will navigate to a page like this (refer the screenshot below).




Now click ADD to select the list of components it will navigate to another page where you will find a dropdown list which will show the list available components for Example we will consider a simple workflow for deployment. 





After choosing workflow rule from the drop down you can see the list of all workflows available for deployment. Choose the required workflows click add to change set.



Now the change set is created for deployment we have to make sure that the dependent components for that chosen components is also added in the outbound change set. To achieve this click on the View/Add Dependencies Button will again navigate to the previous page which will show the list of dependent components. Select all the components available and click  add to change set button and make sure all the dependent components are added in the change set.

Choose appropriate profiles required in the same change set. And click the upload button. Now the components will be added in the production org and a mail will be sent to the Sandbox administrator.

Step #3:
The deployment time might vary from few minutes to few hours. Now log in into production org and navigate to inbound change sets as follows
 User Menu->Setup->App Setup->Deploy->Inbound changeset
Now the user will be able to see the list or inbound change sets which we sent from sandbox.  Will be available in Change Sets Awaiting Deployment section.
 Click the link for the inbound change set in this section now the screen will navigate to the list of components available there you can see Validate and Deploy buttons. Pressing validate button will mock the changes which will be made in the system after deployment and it produces results. So its always a good practice to choose validate button before deploying. If the result is success then the change set is ready to deploy now.

Point to remember before deploying

·         Deployment should be done in a sequential order  to avoid errors I.e in this order
·         Custom Objects
·         Custom fields
·         Profiles
·         Roles
·         Templates
·         Pagelayouts
·         Record Types
·         Email Alerts
·         Field Updates
·         Workflow rules
·         VF pages
·         Test Classes
·         Classes
·         Triggers
·         Validation Rules.

If you press the view dependency button all the available components will be pulled sequentially so the user really have to mind the sequence.





Saturday, June 22, 2013

Autonumber Trigger

This is my third blog and i have a delicious content to post here. I had an requirement to complete like this the client wants an unique Id in the lead section and opportunity section in Salesforce. they might create lead and opportunity manually or either automatically using Rest API transaction. So i planned to create a unique id in lead and opportunity. For example L-38 for lead number 38, O-15 for lead number 15 . I understood what's running in your mind what will happen if the lead is converted ? Even for the converted lead the opportunity number becomes like L-38(even after conversion) so the user can differentiate which is a converted opportunity and which is a manually created opportunity. I came up with the solution of writing trigger to achieve this.

In order to achieve this we have to write two triggers one on lead and one on Opportunity. This is my first trigger on lead

The Main purpose of writing this trigger is to generate a unique number for each record.. So i gave the condition that it has to pick the maximum values among Lead and Opportunity assign a value with maximum number  and concatenate with L and O based on the records.Any way i didn't give condition for concatenation instead i created a formula field instead which will concatenate the number with L and O since the client want the field read only.
Never forget to instantiate the field value else this trigger will wont work so before creating the trigger add default value "0" for the field Lead_Record_ID__c. In order to avoid null pointer exceptions.

The trigger is very simple to understand i queried lead and opportunity and ordered by descending values so that the highest number will be stored in the first index position of the list and the "Limit 1" in the query will store only one value.
 /******  
 ***Created by:Nirmal  
 ***Created Date:22.04.2013  
 ***last modified date:23:04:2013  
 ***Description:This trigger is used to generate a unique ID on Lead  
 ******/  
 trigger AutonumberIDonlead on Lead (before insert) {  
 List leadList=[select Lead_Record_ID__c,Id from Lead where Lead_Record_ID__c !=: null order by Lead_Record_ID__c desc limit 1];  
 List OppList1=[Select Lead_Record_ID__c,Id from Opportunity where Lead_Record_ID__c !=: null order by Lead_Record_ID__c desc limit 1];  
 Decimal maxlead = leadList[0].Lead_Record_ID__c;  
 Decimal maxopp = OppList1[0].Lead_Record_ID__c;  
 for(Lead led :trigger.new){  
 led.Lead_Record_ID__c= Integer.valueOf( ( maxlead > maxopp ? maxlead: maxopp ) +1 ) ;  
 }  
 }  



The next trigger would be the trigger on opportunity similar to the above one and this trigger will work if the isconvertedlead value is false this is good for not generating the autonumber if the opportunity is converted from to a lead..
 /*********************************  
 ***Created by:Nirmal  
 ***Created Date:22.04.2013  
 ***last modified date:23:04:2013  
 ***Description:This trigger is used to generate unique id on opportunity  
 ********************************/  
 trigger Autonumberonopp on Opportunity (after insert) {  
     List<Opportunity> OppList=[SELECT Id,ParentOpportunity__r.Lead_Record_ID__c, Lead_Record_ID__c,Sys_IsConvertedLead__c FROM Opportunity Where ID=:trigger.new[0].id];  
     List <Lead> leadList=[select Lead_Record_ID__c,Id from Lead where Lead_Record_ID__c !=: null order by Lead_Record_ID__c desc limit 1];  
     List <Opportunity> OppList1=[Select Lead_Record_ID__c,Id from Opportunity where Lead_Record_ID__c !=: null order by Lead_Record_ID__c desc limit 1];  
     Decimal maxlead = leadList[0].Lead_Record_ID__c;  
     Decimal maxopp = OppList1[0].Lead_Record_ID__c;  
     for(Opportunity Opp1:OppList){  
         if(Opp1.Lead_Record_ID__c!=null && Opp1.Sys_IsConvertedLead__c==false){  
                    opp1.Lead_Record_ID__c= opp1.ParentOpportunity__c == null ?    Integer.valueOf( ( maxlead > maxopp ? maxlead: maxopp ) +1 ) : opp1.ParentOpportunity__r.Lead_Record_ID__c ;  
       }  
     }  
     update OppList;   
 }  
Both triggers worked fine but the new problem arises from the ashes if the lead is converted what will happen to the existing auto number field. i don't need a new value while converting instead i need the same value in the opportunity section i came up with a different trigger for that.  this trigger will will written on lead i can modify the existing lead trigger to add the condition but in order to make the beginners understand i have created this as a separate trigger.
 trigger autonumberafterconv on Lead (before update) {  
   for(Lead lead:System.Trigger.new) {  
   if (lead.IsConverted) {  
       // Assign the value from the Lead "Status" field to the Contact "Type" field  
       Opportunity opp = [SELECT Id,Contact__c,Lead_Record_ID__c FROM Opportunity WHERE       Id = :lead.ConvertedOpportunityId];  
       opp.Lead_Record_ID__c = lead.Lead_Record_ID__c;  
       update opp;  
     }  
   }  
 }  
In this way we can make the id's unique in lead and opportunity and concatenated with L and O using a  formula field.

Wednesday, June 19, 2013

Sending Email on field change using a trigger


How to send Email to current and former lead owner if there is a change in the owner of the lead record?????
               The answer in simple you can do this by a trigger using messaging.single email message class. The scenario for me was like this in a lead record if there is a change in the lead owner a notification email has to be sent to the previous owner and current owner i've posted the code below for your reference.
 /*************  
 *******Created by:Nirmal Christopher  
 *******Created Date:02.05.2013  
 *******Description:Email will be sent if the owner is changed to new owner and old owner of the respective lead record  
 *************/  
 trigger SendEmailOnOwnerChange on Lead (before update,After Update) {  
   if (trigger.old[0].OwnerId != trigger.new[0].OwnerId ) {  
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
     //Select the Email Address of the old owner  
     String emailAddrnew = [select Email from User where Id = :trigger.old[0].OwnerId].Email;  
     String emailAddrold = [select Email from User where Id = :trigger.new[0].OwnerId].Email;  
     //Select the new owner and old owner from user  
     String newOwnerName = [select Name from User where Id = :trigger.new[0].OwnerId].Name;  
     String oldownerName=[select name from User where Id =:trigger.old[0].OwnerId].Name;  
     //Store the email address  
     String[] emailAddrnew1 = new String[] {emailAddrnew};  
     String[] emailAddrold1 = new string[]{emailAddrold};  
     mail.setToAddresses(emailAddrnew1 );  
     mail.setCcAddresses(emailAddrold1 );  
     mail.setSubject('Owner Changed for Lead : ' + trigger.new[0].Name);  
     mail.setPlainTextBody('Owner of lead: ' + oldownerName + ' Changed to ' + newOwnerName);  
     mail.setHtmlBody('This is to notify that the Owner of lead: https://ap1.salesforce.com/ <b>' + trigger.new[0].Id+'<b>&nbsp;&nbsp;Changed from</b>&nbsp;&nbsp;'+oldownerName + '</b>&nbsp;&nbsp; Changed to <b>' + newOwnerName + '</b>');  
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  
   }  
 }  

hope this helps 

Email handler class-Salesforce

How to mock the Email to Salesforce Functionality using a inbound handler class?.....

 There might be certain cases where you have to mock the email to salesforce feature in my case the scenario was like this i wanted to integrate the sales user's Gmail Account with Salesforce so if the sales user receives the E-mail it will get auto forwarded to SFDC so that it have to create activity history logs in the related records. I can use the standard  Email to salesforce feature but the problem is Google sends the verification code to the target email address while setting up the auto forwarding feature so i wanted to fetch the verification code first where as SFDC dont have a feature to display the verification code sent via email to salesforce addres. To acheive this i have to create a inbound E-mail handler class for this. So the class which i created will automatically create tasks and activity history in all its associated records in Contact,Account and Opportunity object from the incoming email of the SFDC user's G mail address. In contacts and accounts we can associate the tasks and activity history since the Email field in contacts is related with accounts in some way. But what for opportunities?

    luckily we have something called opportunity contact roles we can query the opportunity contact role and if there is an match in the email adddress from the incoming Gmail address  with contact email address in Opportunity contact role an activity history and tasks will be created automatically.
      Similarly the activity history will be created in Accounts and  Contacts if there is an match in the email address. I've posted the code for reference below.
 /****************  
 Created by:Nirmal Christopher  
 Created Date:03.05.2013  
 Decription: from the incoming mail tasks will be created for Leads,Accounts and Opportunity  
 ****************/  
 global class GetVerificationCode implements Messaging.InboundEmailHandler {  
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope envelope) {  
  system.debug(email);  
  system.debug(envelope);  
  Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();  
    String mail = email.fromAddress;  
    list<Task> opptask = new list<Task>();  
    list<Task> ltask = new list<Task>();    
    list<task>ctask=new list<task>();   
    list<OpportunityContactRole> ocr= [select OpportunityId,ContactId from OpportunityContactRole where Contact.Email=:mail ];  
    Set<Id> opportunityIdSet = new Set<Id>();  
    for(OpportunityContactRole o:ocr){  
      opportunityIdSet.add(o.OpportunityId);  
    }  
    list<Opportunity> opportunitylist=[select id from opportunity where id in: opportunityIdSet];  
     System.debug('********************************'+opportunitylist.size());  
    list<lead> leadTask =[Select id,email from lead where Email=:mail];   
    list<contact>contask=[select id,email from contact where Email=:mail];  
    System.debug('********************************'+contask.size());  
    //Inserting Opportunity Task  
   for(Opportunity o:opportunitylist)  
    {  
    Task tsk=new Task();  
    tsk.Subject = email.Subject;  
    tsk.OwnerId=UserInfo.getUserId();  
    tsk.Description = email.plainTextBody;  
    tsk.WhatId = o.id;  
    tsk.status = 'Completed';  
    tsk.Type__c='Recieved';  
    tsk.SYS_Check_Task_Creation__c=false;  
    opptask.add(tsk);  
    }  
    try{  
    insert opptask;  
    }catch(DmlException e){  
      System.debug('********opptask******'+e);  
    }   
   //Inserting Contacts Task  
   for(contact con:contask){  
    Task tsk1=new Task();  
    tsk1.Subject = email.Subject;  
    tsk1.OwnerId=UserInfo.getUserId();  
    tsk1.Description = email.plainTextBody;  
    tsk1.WhoId = con.Id;  
    tsk1.status = 'Completed';  
    tsk1.Type__c='Recieved';  
    tsk1.SYS_Check_Task_Creation__c=false;   
    ctask.add(tsk1);   
    }    
    try{  
    insert ctask;  
     System.debug('*******contask*******'+ctask);  
    }catch(DmlException e){  
      System.debug('*******contask*******'+e);  
    }  
   //Inserting Lead task  
    for(Lead lt:leadTask)  
    {  
    Task tsk2=new Task();  
    tsk2.Subject = email.Subject;  
    tsk2.OwnerId=UserInfo.getUserId();  
    tsk2.Description = email.plainTextBody;  
    tsk2.WhoId = lt.ID;  
    tsk2.status = 'Completed';  
    tsk2.Type__c='Recieved';  
    tsk2.SYS_Check_Task_Creation__c=false;  
    ltask.add(tsk2);  
    }  
    try{  
    insert ltask;  
    System.debug('**************'+ltask);  
    }catch(DmlException e){  
      System.debug('**************'+e);  
    }   
     return result ;  
  }  
 }  

By this way we can mock the standard E-mail to Salesforce feature using a Apex email handler class.

          After writing the class you have to enable email service feature in salesforce. You can access email services feature like this setup-->develop-->Email services and create a new email service . For the class choose the class which we created above click save it will generate a email service address, Use the email service address in your Gmail account's auto forwarding feature it will prompt you for a verification code  and a code will be sent to the auto forwarding address which you added you can capture the verifiction code in the debug logs. That's it....tadahhhhh your g mail account and SFDC instance is now integrated. create few filters in your Gmail account as required to forward specific emails in SFDC instance. So from the incoming email tasks will be created as activity history in Leads,contacts and Opportunities if there is a match in the incoming email address.