• gnatrae
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

 

I have a requirement to show # of open Task on Lead Detailpage. Below is the logic that we are planning to implement. I would like tocheck with you if any one has implemented similar functionality handling BULK insert/update.If so could you please share the code?

 

Trigger on Task <after insert after update>

 

{

    for (Task thistask : Trigger.new)

      {

    // Get all leads assosited to Tasks

    if (WhoId.startsWith('00Q'))               

      leadIdToUpdateList.add(taskWhoId.WhoId);

     }

 

FOR each Lead

           SelectCount() from Task where whoId=LeadId and Status=Completed

           Updatecustom field “ Open Task” on  Lead object

End Loop   

 

}

 

Thank You .