Migrating / Importing data and maintaining Created By, Modified By and Modified On

When importing or migrating data to a Dynamics 365 / CRM environment you cannot migrate the fields Created By, Modified By and Modified On. Most customers won’t bother about it until it comes down to the migration of ‘old’ activities. By default, the Social Panes show activities sorted on the Modified On date. So when you migrate data and all activities have ‘today’ as the Modified On date, you’ll get problems with the sorting of activities.

Migrating the data and setting the fields

As you know, it’s not possible to set the values of the Created By, Modified By and Modified On date. That is when you try to set this data directly. Lucky for us, when using the SDK it is actually possible to set the values of those fields. The solution contains a plugin that does this:

  • At the creation of a record, check if the field ‘dnbs_overriddencreatedby’ contains a value. If so, set the field createdby to that value.
  • At updating a record, check if the field ‘dnbs_overriddenmodifiedby’ contains a value. If so, set the field modifiedby to that value.
  • At updating a record, check if the field ‘dnbs_overriddenmodifiedon’ contains a value. If so, set the field modifiedon to that value.

In order to make this work for your data migration or data import, just make sure you set the values of the fields ‘dnbs_overriddencreatedby’, ‘dnbs_overriddenmodifiedby’ and ‘dnbs_overriddenmodifiedon’. These are the schema names of the fields. The display names are: Overridden Created By, Overridden Modified By and Overridden Modified On. When you import the solution, these fields are available on these entities:

  • Appointment
  • E-mail
  • Letter
  • Phonecall
  • Taks

The solution is extensible

The plugin inside the solution is setup to fire off on all entities. This means that you can extend the use of this plugin to all other entities. When you want to use the same method on the Account entity, for instance. You just need to make sure you create these fields on that entity. The schema names of those fields must exactly match these names.

  • dnbs_overriddencreatedby as a Lookup to the User entity;
  • dnbs_overriddenmodifiedby as a Lookup to the User entity;
  • dnbs_overriddenmodifiedon as a Date and Time field.

Don’t forget to delete the solution!

When you are done with migrating or importing your data, don’t forget to delete the solution! As you have seen above, the plugin fires off at all updates. This is a loss to your performance and also you might get into trouble with the Modified By and Modified On fields not being updated right.

Download your solution here

Download

The source code can be found here

https://github.com/marcgerner/D365ActivityMigration

24 thoughts on “Migrating / Importing data and maintaining Created By, Modified By and Modified On

  1. Hi Marc, your override modifiedon Plugin only seems to work for Closed activities, and does not work for open activities? Will you be planning on fixing this anytime soon, or shall I develop a fix for this which im happy to do?
    Many Thanks for your effort!

    1. Hi Raz, the solution works for both open and closed activites with me. Is there anything else that might be blocking here? I’ll be happy send you the sourcecode if you want to 🙂

    2. Hi Marc I can confirm this solution works as expected, I think the Asynchronous service took some time to catchup with large data loads but the modifiedon and createdon dates do eventually get updated. Thanks again!

  2. Hi Marc,

    Thank you for the brilliant solution. I did tried this and initially modified on date placed in Override Modified On field then once I do the update to the record then original datetime from Override Modified On field is transferring on to Modified On field.

    Is it possible to transfer the Modified on field date from OverrideModifiedOn onto Modified On without doing any updates.

    Please suggest!!

    1. Hi Krishna,

      Sorry for my late response. The only wat to update data without doing an update is updating the SQL tables. Obviously that can’t be done in an Online environment, but it can in an OnPrem environment.

  3. Hi Marc,

    This solution work for only completed activities for us. Can you please give some guidance please ?

    Thanks

    Rasha

    1. Hi Rasha,

      Can you check the plugin steps? I’m not sure about the steps. Maybe the steps in the solution are only on statechange and not on create/update.

  4. Hi Marc,

    Great idea for a solution.

    We are having a similar issue with updates to modified by and modified on.

    I can only seem to get it to update close\completed activities.

    If the activity is open and we have data in the override (modified) fields nothing happens.

    if we then export the date and change the status to close/completed the update works for the override modified fields.

    Is this expected or are we missing something?

    Any help would be appreciated.

    We are using the latest version of D365 online V9

    Thanks,
    Peter

    1. Hi Peter,

      Can you check the plugin steps? I’m not sure about the steps. Maybe the steps in the solution are only on statechange and not on create/update.

      Also good to know is I haven’t tested the solution on V9, although I think it should work. Can you let me know if it works for you?

  5. Hi Marc,

    This solution looks great, but it can’t be imported into a v8.1 environment (CRM 2016). Is it possible for you to provide a copy of the managed solution that could be used in an earlier environment?

    Cheers,

    Ryan

    1. Hi Ryan,

      I’ve send you the source code. Can you let me know if this works out for you?

      Cheers,
      Marc

    1. Haha thanks! I have to admit I haven’t thought about the annotation entity before. You’re right my solution doesn’t work for this entity… I’m afraid I don’t have a solution for this yet

  6. Hi Marc,
    it sounds to be a great solution for my import problems, but I don’t get it work.
    I’m working an a D365 platform (V9) and successfully imported the solution.
    I imported some previously exported datasets and assigned (only) the modified on date to your field in the email object.
    The reimport was successful, but the date did not change.

    Is there anything to do to trigger the task?

    Cheers, Bernd

  7. Hello Marc,

    all SDK entities seem to be imported, the objects have the additional fields, but there are no updates on my (email) objects, when I import them via Excel.
    Fields are sucessfully filled.
    I’m using D365 V9.

    Is there anything to do after importing the solution?

    Cheers, Bernd

    1. Hi Bernd,

      Sorry to not coming back to you any sooner. Apparently my e-mail notification don’t work anymore since I didn’t receive an e-mail of your comment.

      I have to admit I haven’t tested the solution on v9 yet, but think it should work. Two questions here:
      – Do the custom fields have a value (i.e. ‘Overridden Modified On’)?
      – Has there been an update on the email? Maybe the record has only been created. I thought it would only work on an update.

      Let me know!

  8. So, once the legacy data has been imported into CRM into my custom entity, I delete the solution; but can I delete the three fields as well?

    Also, do the modified by and created by users need to be created as actual system users in CRM? I have legacy users who have long since gone. Do I need to pre-create these users in CRM before importing? If so, can they be de-activated users?

    Thanks

    1. Hi Lorne,

      Yes, please delete the three fields. If you don’t the ModifiedOn will never change.

      You can pre-create the legacy users as stub-users. Microsoft has this solution in place for you. Simply just import the users via Excel. They won’t be able to login, but you will have the users in place for migration purposes. See also https://docs.microsoft.com/en-us/dynamics365/customer-engagement/admin/create-users-assign-online-security-roles#how-stub-users-are-created

  9. Does this add-on still work in Version 1710 (9.1.0.35) online? It always worked fine, but now my fields values are not being updated.

    1. Hi Michel,

      I’ve tested it on 9.1 and seems to work fine for me. Have you found another issue or is it still not working?

      Cheers,
      Marc

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.