The usefulness of Dynamics CRM's modifiedon field is limited.
We can do better.

The out-of-box modifiedon field tells you when the last time any change was made to a record. The CRM platform creates and manages the modifiedon field for all built-in and custom entities.  

See below the modifiedon field shows 3/31/2021 @ 4:05pm:

The problem with modifiedon is that any update to the record causes this date to be updated.  The platform tracks all fields’ changes whether they’re updated by an end-user, some plugin, workflow or integration processes etc….

Even if you update a field to a value that is the same as the value it held previously, the modifiedon field will get updated to the current date/time. 

 

These issues mean the built-in modifiedon has little real-world value. A poorly designed integration process could be running periodically and updating records with the same data that was there before and updating up the modifiedon date in the process. When was the last time the record actually changed? You don’t know.

 

There is a better way…

AutoMerge’s Modifiedon (gnb_automergemodifiedon) was designed to track if a change occurs to a custom set of fields on any entity. It works in conjunction with our plugin to watch for actual changes where the updated value written to a field is different from whatever the existing value was.

See below the earlier date of 1/26/2021 @ 2:53pm

 

The “AM ModifiedOn” field shows an earlier date because it is configured to update only when certain fields are updated. And by updated I mean actually updated to new values (or cleared of previous values)

We added this functionality to AutoMerge primarily for ranking purposes. When the AutoMerge analysis finds a duplicate set and you want the most recently updated record to be set to Rank=1 (in other words to win the eventual automerge operation) then it isn’t enough to use the OOB modifiedon field. For the purposes of ranking the records in the  duplicate-set, we are only interested in changes to a small set of fields like: firstname, lastname, mobilephone, emailaddress1, etc… We dub these “Watch Fields”

How to turn on this functionality and configure the watched fields.

Pre-requisites

 

Steps to set up the automation:

Add an Update plugin steps for the entity you wish to track (this example for the Contact entity)

  1. Open the Plugin Registration tool and connect to your CRM Org as a user with the System Administrator security role.
  2. Locate the (Assembly) GenbilMerger.Plugins line and expand it.
  3. Then locate the line (Plugin) GenbilMerger.Plugins.All_SetAutoMergeLastModifiedOn_PreUpdate
  4. Right-click on that line and select Register New Step
  5. In the new dialog that appears, enter…
    • Message: “Update”
    • Primary Entity: “Contact” (or whatever entity you are tracking)
    • Secondary Entity:
    • Filtering Attributes: Select the fields you would like to track. We are only tracking mobilephone in this example.
    • Event Handler: leave default as is
    • Step Name: leave default as is
    • Run in User’s Context: leave as “Calling User” (though you could change this if you know what you are doing)
    • Execution Order: leave default “1”
    • Description: leave default as is
    • Set the Event-Pipeline-Stage-of-Execution: “PreValidation”
    • Execution Mode: Synchronous
    • Deployment: Server only
    • Click the Register New Step button to close that dialog.

      Then…

    • Right-click on the new Step just created and choose Register New Image, and in the new dialog set the following
    • Image Type: “Pre Image”
    • Name: leave blank
    • Entity Alias: “PreImage”
    • Parameters: Select the fields you would like to track. For simplicity, we are only tracking mobilephone in this example.
  •  

Then add a Create plugin step

This is mostly the same as the Update Step we did above with a few differences (highlighted)

  1. Open the Plugin Registration tool and connect to your CRM Org as a user with the System Administrator security role.
  2. Locate the (Assembly) GenbilMerger.Plugins line and expand it.
  3. Then locate the line (Plugin) GenbilMerger.Plugins.All_SetAutoMergeLastModifiedOn_PreCreate
  4. Right-click on that line and select Register New Step
  5. In the new dialog that appears, enter…
    • Message: “Create
    • Primary Entity: “Contact” (or whatever entity you are tracking)
    • Secondary Entity: <empty>
    • Filtering Attributes: Select the fields you would like to track. We are only tracking mobilephone in this example. (not applicable to Create event)
    • Event Handler: leave default as is
    • Step Name: leave default as is
    • Run in User’s Context: leave as “Calling User” (though you could change this if you know what you are doing)
    • Execution Order: leave default “1”
    • Description: leave default as is
    • Set the Event-Pipeline-Stage-of-Execution: “PreOperation
    • Execution Mode: Synchronous
    • Deployment: Server only
    • Finally – click the Register New Step button to close that dialog.
    • No need to Register a PreImage for the Create event

Next Edit the watch-field list in the AutoMerge-Configuration record corresponding to the entity you are working.  When the above plugin steps fire, it looks for a watch-field AutoMerge-Configuration record associated with the Contact entity. If you have an active AutoMerge subscription you will find some default watch-field records for Account, Contact and Lead. You can edit those as necessary, or create your own.

Click open the Advanced Find and look for “AutoMerge Configuration” records. (No filtering criteria needed) 

After getting the Results, open up the Contact-Watchfield-List record. Or create one if it doesn’t exist.

Finally – edit the config record, giving it a comma-separated list of schemanames for the fields you wish to watch for changes. In this example we are only watching the mobilephone field. 

That’s it!

Now as new Contact records are created, the am_automergemodifiedon date will initialize to the create date, and from then on that date field will only update when the mobilephone field is updated to a new value (or cleared)

Initializing the am_automergemodifiedon date field for existing records.

All the Contacts that existed in your CRM system prior to your setting up this automation aren’t going to have anything in the am_automergemodifiedon field. If you want those dates initialized to something (example createdon), you will have to do it yourself.

One way to do that: you could create a simple workflow (or Power Automate flow) rule that copies the createdon date to the am_automergemodifiedon field, and use the XrmToolBox’s Bulk Workflow Execution tool to trigger that workflow on a defined set of records.

If you have an active AutoMerge subscription, we will do it for you. Just email amsupport@genbil.com and we can initialize that field for you (since it is one of the fields in our managed solution). Tell us in simple terms how you want am_automergemodifiedon initialized. We can populate that field with any date field on that entity or a parent (N:1) entity or some time offset thereof. Or likely whatever date logic you can dream up.

Happy AutoMerging!