On a recent project, the organization had an interesting requirement: capturing a last activity date/time, and a next activity date/time. This data could be used by the sales team to monitor engagement through the sales process. For this, it would have been easy enough to add the fields to the appropriate entities in Dynamics 365 and leave these for manual update. Of course, that would be too easy, and I wanted a way to automate this. While this could have probably been accomplished with code, I wanted to contain this to configuration.
My basic approach was to create custom date/time roll-up fields at any entity where we needed to capture this data. For this, we used: Lead, Contact (this was the primary representation of a customer, not Account), and Opportunity. While we excluded Account, you may need to include this for your organization. These fields for future reference in this are: Last Activity Date/Time, and Next Activity Date/Time.
In your solution, create fields: Last Activity Date/Time and Next Activity Date/Time on each entity to collect this information (again, for this it was: Lead, Contact, and Opportunity). Choose whether or not you want these fields on your respective forms, add them as needed. If adding to your forms, you may want to consider making these read-only.
For field: Next Activity date/Time, use the logic below. Adjust the field so it makes sense for your organization:
For field: Last Activity Date/Time, use the logic below. Adjust the field so the values make sense for you organization:
Going forward, Next Activity Date/Time should be updated based on the most recent, upcoming activity. Last Activity Date/Time should be updated based on the most recently completed activity. Keep in mind, there is a timing limitation here based on the most recent roll-up calculation. Based on this, these fields should be used for general reference, as they may not be 100% accurate.