Is it possible to create a rollup summary field on Contact to count the activities. For example, count the total number of times 'Log a call', total number of times 'log a meeting', and total number of times 'Log an email'?

  • I highly doubt that if it's possible you can't create a master-detail relationship with a standard object on the detail side and without being a relationship you can't create a Roll-Up summary
    – user56430
    Mar 3, 2021 at 13:43

1 Answer 1


Rollup summary fields can only be used on Master-Detail relationships where you wish to rollup child information to the parent i.e detail to master.

In this case, you need to use Apex. A declarative tool like Flow is possible but to ensure you are working from the correct Related To Sobject, you will need to invoked Apex.

Sample Apex:

List<Id> conIds = new List<Id>();
for (Task t : Trigger.New) {
    if ((t.WhoId.getSObjectType() == Contact.sObjectType) && t.Subject == 'Log a Call') {

if (conIds.size() > 0) {
    List<Contact> cons = [select id, CallLogs__c from Contact where id in :conIds];
    for (Contact con : cons) {
        if (con.CallLogs__c == null) con.CallLogs__c = 1;
        else con.CallLogs__c += 1;
    update cons;

A custom Number field has been added to the Contact object to count the specific number of "Log a Call" Tasks. You may wish to aggregate all Task Subjects in a single field, thats a design choice on your side. Another design decision for you is to build a known of set of Task subjects to check against. Note the check on WhoId.getSObjectType() as Task is a shared object and you want to safe guard your code for later operations.

You should extend this Apex to accommodate delete operations if you wish to decrement the count on the Contact record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .