Search code examples
dynamics-crmdynamics-crm-2011dynamics-crm-2013dynamics-crm-2015dynamics-crm-2016

CRM 2016 Date of Last Email Calculation


We desperately need a 'Date of Last Email' field on the Company record in CRM.

Initially we tried to use a rollup field over 'Email Messages (Regarding)'. This only works for emails that have the company in the 'Regarding' field on the email.

There are many emails that are visible on the Activities Social Pane which are not set as regarding this company. They have been tracked to a person who works for this company. There seems to be no way to capture these emails in a "Date of Last Email" type of field.

Has anyone found a way to capture this? It seems like a common requirement.


Solution

  • There are several approaches here:

    1.Plug-in You can have a plug-in execute against the SetState message of the Email entity. When you identify that the email message was Sent, you can query the ActivityParty entity in order to identify the contacts present on the TO/CC/BCC lines, and update the Last Email Data field for those records. Note that it is not necessary to use the Regarding field here. Please, bare in mind the performance considerations here, since this message will execute basically for every email record in CRM.

    2.Web Resource You can add a Web Resource to the contact form that will read the contact's email address and query the ActivityParty and Email entities in order to identify the last date and time they participated on an email activity. This Web Resource would just show this information on the form, not populating any fields in the contact form.

    3.Retrieve/RetrieveMultiple plug-in Probably not the best option, but you can use the same approach here as to the Web Resource. When a contact is retrieved, you can query the ActivityParty and Email entities and populate your custom attribute within the contact entity. This will provide you with a "virtual" field containing the information you want, but may have considerable performance implications.

    Source: https://community.dynamics.com/crm/f/117/t/168906