+ Start a Discussion
madhavi mishramadhavi mishra 

emailmessage and lead

Hi,The  lead object  has a field "Interaction count" . It is a number field. I am using this field for  an active process builder  which is working  on the below criteria:
If any Task is created , It will add+1 to the "Interaction Count "Field. If I am creating Task by using" LoginActivity" , my interaction count is showing a increment which is good.
But If I am using "Email" , and sending an Email to the vendors, It is not considering as a Task and there is no increment in the " Interaction Count "Field. I tried Process builder and Flow but  not worked out. Can we do via "Apex coding" Any help is appreciated...
Also I have to create custome button and use Trigger
Thanks  
Uttpal_ChandraUttpal_Chandra
Hi Madhavi,

Try using trigger you can di it easily
madhavi mishramadhavi mishra
Hi Uttpal,

I did .. Here it is..

 trigger populateParentAccount on Lead(after update) {
      account Account = new Account(0);
      For (Lead theLead:Trigger.new)

    // Check to see if the lead was converted into an Account

{ if(theLead.ConvertedAccountId!= null)


}
      Set<Id> accountIds = new Set<Id>();
      for(Lead record: [SELECT ConvertedAccountId, Agency_Account__c FROM Lead WHERE ConvertedAccountId = :Trigger.new ORDER BY ConvertedDate DESC]) {
        // Avoid multiple leads with same account 
        if(!accountIds.add(record.ConvertedAccountId)) { 
          updates.add(new Account(Id=record.ConvertedAccountId, ParentId=record.Agency_Account__c));
        }
      }
      update Account;
    }
But not working..
please help..
Thanks
mitu
Uttpal_ChandraUttpal_Chandra

Hi Madhavi,

Since Apex triggers are object specific and Task and Email both are different object so you seprately write trigger or create 2 processbuilder for it.