2

I have a custom object with Activities enabled, as such it has the child relationship ActivityHistories - I wanted to show a count() of the related Activities associated w/ each object of a certain type:

COUNT(WHERE ActivityHistory.Type = 'Call')

Is this possible in a Formula Field? I don't see any merge fields for it, and I can't create a Roll-Up Summary (inactive the field editor UI, so I assume it's not available that way?)

Or do I have to write a custom trigger and update it when the Task is inserted?

  • I reckon best bet would be 2 roll-up summaries on Tasks and Events (completed/closed) and then a formula field to sum the two roll-up summaries. – Boris Bachovski Jul 17 '15 at 1:44
  • @Bachovski still ActivityHistories is not an available merge field for formula's on my custom object? – jordan.baucke Jul 17 '15 at 6:49
  • ActivityHistories represent either a Task or an Event that is completed. So your roll up summary would be on both task and event objects. In your formula you'll sum both roll up summary fields – Boris Bachovski Jul 17 '15 at 8:23
  • I dont think we can create roll up summaries in this case. – Amit Bangad Jul 17 '15 at 8:39
1

You will have to write an Apex Trigger. The trigger should fire and work on multiple events, like

insert - if a closed activity (even or task is inserted)(+count)
update - if open activity is closed (+count) if closed activity is opened(-count)
delete - if closed activity is deleted (-count)
undelete - if a deleted closed activity is restored.

Let me guide you to a link that can help you to write this trigger. This link calculated count for OpenActivities, all you have to do is apply your logics and count for ActivityHistory.

http://rjpalombo.com/2013/11/counting-open-activities-salesforce/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.