Salesforce APEX Introduction - After Insert, After Update to Count Tasks Assigned to a Contact

preview_player
Показать описание
In this video, I show you how to use APEX code to create a column on your Contacts object that sums up a Contact's total current assigned tasks that aren't completed.

You can alternatively repeat the same process but write over Contact with Lead, ContactMap with LeadMap, and ContactIds with LeadIDs without even thinking per below code:
before insert:

trigger null2 on Lead (before insert) {
con.No_of_Open_Tasks__c = 0;
}
}

remaining code with updated Lead table instead of contact table containing the aggregating column:

Remaining code but with Lead table and Contact table both aggregating if a task is assigned to either a Lead or a Contact:

Now when you assign tasks to Leads, you can aggregate the total tasks assigned to Leads or to Contacts as they increment and decrement. You can use the Process Builder to auto-assign tasks to Leads or Contacts while the Lead Assignment Rules or Workflow Rules auto-assign the Rules to Users or Queues too based on other criteria. Your "Contacts" and "Leads" can become a sub-user with their own tasks assigned to them in a visual column with this code.
Рекомендации по теме