|Summary:||This article highlights the experience that our team .have had when modifying silently in Dynamics 365 – not affecting the modified by and modified on values of historic records.|
|Article Type:||Information, Tips, How-To|
|Related Product(s):||This article relates to the following products:
Tips for Modifying Silently in Dynamics 365
As part of a recent custom change to Microsoft Dynamics 365 we wanted to make use of the Sort Date field on Activities. Populating this field moving forward was achieved using a plugin that would execute each time a new record was created. There was however a large number of existing records already in the system that needed this Sort Date field back populated.
In this particular scenario we did not want to affect the modified by and modified on values of each of these historic records, so a solution was put in place to achieve this.
We created a new plugin containing the following generic script:
Once this new plugin assembly had been registered within Dynamics 365, we were ready to set up the steps for each entity that we wanted to preserve the modification dates of.
Using register new step, we set the Message to “Update”, and Primary Entity to the entity that we wanted to preserve the Created/Modified Date/By of. Then we needed to ensure that the option for Pre-operation had been selected and the execution mode was Synchronous. After saving the settings, we proceeded to register a new image for the step we had just created.
We set the Image Type to “Pre-Image”, the Name to “PreImage”, and the Entity Alias to “PreImage”. In the parameters selection we checked only createdon, createdby, modifiedon, and modifiedby (these are the only required properties) before saving the new image.
Prior to executing the updates on each entity, we simply enable the appropriate step in the plugin. The records could then be updated without affecting the modified by/on fields. Once completed, we disable the step so that modified by/on will be recorded again.
Disclaimer: This approach is provided “as is” and QGate accept no responsibility for loss or corruption of data either directly or indirectly from the use of this approach.