function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

open activities



I want to display a field in the contact with an option yes or no ,  so if there is any open activity assosciated with that contact it shows yes else no....


any ideas, solutions , approach will be really appreciated


thank you






      It is not possible to have a field in contact that will display a specific value on the basis of OpenActivities.

The reason bieng the way system works. It is not possible to track Closed events as compared to closed tasks. Instead, I would suggest to make an inline Visualforce page in contact that will show a field like display to show a mere yes/no based on number of Open Activities. The controller corresponding to VF is capable enough to show yes/no based on the current data.


If it is quite important to have a field, let the inline vf page be in page layout to view correct data ; and code the controller to update the current contact record after evaluation of yes/no.




I have written a trigger which works fine if , i have task created after an contact is created . But I have a situation where a task is created at the same time when an contact record is created .So, it doesn't allow me to update the contact record.

I have created a custom field in contact for counting the total open activities.

i would really appreciate any help in solving this...thank you


trigger CountContact on Task (after insert,after update  )
        if(Trigger.IsUpdate || Trigger.IsInsert)
       String ContactId = Trigger.New[0].whoId;  
       if(ContactId.substring(0,3) =='003')
            List<Task> Tasks = [Select Id from Task where Status =: 'Not Started' and whoId =: ContactId ];
            Contact C = [Select id,Total_open_Activity__c from Contact where Id =:Trigger.New[0].WhoId]  ;
            C.Total_open_Activity__c = Tasks.size();
         //   update C;