+ Start a Discussion

Update custom lead field based on a custom activity field

I have a custom field (EmailCount) on the Activity tab that gives me a count of certain types of activities.  What I would like is for this field to be populated onto the Lead tab into another custom field (EmailCountLead).


I would have liked have done this through work rules, but I don't see the needed fields.




I tried the workflow rule for the similar reason, and it seems like it only allows field update for the related objects. I guess Activity isn't related to Account, therefore fields in Account do not show up in field update.


I'm a newbie myself, so I can't give you the perfect solution, but I would just write a trigger. Something like this...


trigger <name of the trigger> on Task (after update) {

for (Task updatedTask : trigger.new) {

for(Account a : [SELECT id, EmailCountLead__c FROM Account WHERE Account.id =:updatedTask.AccountId]){


a.EmailCountLead__c = updatedTask.EmailCount__c;

  update a;





I just quickly drafted this so you'll have clean it up and see if it works.
Message Edited by cinfidel on 11-06-2009 02:59 PM

Oops sorry, you said Lead, not account. THe above code I wrote assumed the custom field is in account...


I don't think there is any reference in task that links to Lead... meaning there isn't any connection between task sobject and lead sobject. I hope other people can help you about this. I'm leaving my other post just in case.