I have been asked several times in the past to develop a solution to keep track of the last activity date for an account or a contact. In Microsoft Dynamics CRM, (which will be rolling into Dynamics 365) activities are used to keep track of all customer interactions. For example; you can send emails, make phone calls, set up appointments, and delegate tasks. This is usually done by creating a date/time field that gets updated when the last activity occurs.
Previously, I would custom design multiple workflows to keep track of each type of activity. For example; a workflow for a Phone Call could be created to monitor the latest Phone Call activity, or I would use a pre-built third-party solution to achieve the same result.
These methods are either tedious to set up or require future maintenance. I am going to share a quick solution to this requirement, with the help of the rollup field and aggregation function.
The idea behind this is that every activity, when created, is also recorded into the Activity entity, so this method simply tracks the Activity entity, instead of each type of activity. The setup is quite straightforward. First, create a rollup field with date/time format.
Second, set the related entity of the rollup field to “Activities (Regarding)”, and aggression set to “Max of Actual End”. In this example, when any activity is marked complete and set regarding an account, the last completion date (Max of Actual End) will become the last activity date.
Quite often activities are set in regard to an Account’s child records, for example, Opportunities. To get the full picture of all interactions, it is extremely important to set “Include indirectly related activities”, as this will track activities that occurred among child records. For example, a Phone Call is set in regard to an Opportunity, instead of to an Account, but this Phone Call will be counted as the last activity for the Account of the Opportunity, and the completion date of this Phone Call the last activity date. (However; this does not work with Task as the related activity, as it does not contain activity party.)
The same thing can be said about campaign activities. All campaign activities are set in regards to the campaign, not the Account or Contact, so with the indirectly related activities enabled, the last campaign activity date will be rolled up as the Last Activity Date. (There is also an OOB field on Account and Contact; Last Campaign Date, which gets updated behind the scenes when a campaign activity is created, so this Last Activity Date has the logic.)
This solution is only made possible with the progressive release of Dynamics CRM (Dynamics 365). With every release there are always new features and enhancements that make development and deployment easier. Such features are often suggested and voted on by customers and partners on Microsoft Connect, where you can contribute and be heard in the Dynamics community.
Dynamics 365 CE (CRM) How-To eGuide
41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 Customer Engagement (CRM). Includes interactions with PowerApps and Flow!Get the eGuide