You need to sign in to do that
Don't have an account?
Call Count Trigger
Hello All,
I'm trying to create a variable that tracks the number of calls performed on a lead. I thought this would be really simple to do as a formula or with workflow rules, but I couldn't actually figure out a simple way to do it without using Apex. I modified an existing trigger I had created, and I thought I had a functional piece of code, but it doesn't work at all. What I have right now looks like this:
trigger callCountUpdate on Task (after insert) {
map<id,lead> leads = new map<id,lead>(), updates = new map<id,lead>();
for(task record:trigger.new)
if(record.whoid!=null&&record.whoid.getsobjecttype()==lead.sobjecttype)
leads.put(record.whoid,null);
leads.putall([select id,call_count__c from lead where id in :leads.keyset()]);
for(task record:trigger.new){
if(record.type == 'Call'){
updates.put(record.whoid,new lead(id=record.whoid,call_count__c = leads.get(record.whoid).call_count__c++));
}
}
update updates.values();
}
Can anyone help me figure this out, or just tell me a way to track this without using Apex?
Thanks very much!
Not sure if this is the complete code, you're not declaring an "updates" variable anywhere so I'm not sure how it would compile.
Something like this should work: