Track Last Activity Date in Dynamics 365 for Sales
Many clients ask us to develop a solution to keep track of the last activity date for an account or a contact. In Microsoft Dynamics 365 CRM (otherwise known as CE) 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, we would design multiple custom workflows to keep track of each type of activity. For example; a workflow could be created to monitor the latest phone call activity, or we would use a third-party app from AppSource to achieve the same result.
These methods are either tedious to set up or require future maintenance. We are going to share a quick solution to this requirement, with the help of the rollup field and aggregation function.
The idea behind this solution is that every activity, when created, is also recorded into the Activity entity. Therefore, this method simply tracks the Activity entity, instead of each activity type. The setup is quite straightforward. First, we need to create a rollup field with a date/time format.

Second, we need to set the related entity of the rollup field to Activities (Regarding), and aggregation 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 regarding an Account’s child records, such as opportunities. To get the full picture of all interactions, it is extremely important to include indirectly related activities, as this will track activities that occurred among child records. If a phone call is set concerning an opportunity, instead of an account, this phone call will be counted as the last activity for the account of the opportunity. The value of the last activity date will be changed to the date of that phone call. However, this does not work with the task activity type, as it does not contain an activity party.
The same thing can be said about campaign activities. All campaign activities are set regarding the campaign, not the Account or Contact. Hence, with the indirectly related activities enabled, the last campaign activity date will be rolled up as the Last Activity Date. There is also an out-of-the-box field on account and contact named Last Campaign Date, which gets updated behind the scenes when a campaign activity is created. The logic of our solution follows the same concept.
This solution was only made possible with the newer releases of Dynamics 365 for Sales. 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 Ideas, where you can contribute and be heard in the Dynamics community.
Please contact us if you have any questions about using Microsoft Dynamics 365 CRM (otherwise known as CE).
41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 CRM apps. Includes interactions with Power Apps and Power Automate!