Sunday, May 14, 2017

Update Modified-On Field using Kingsway Soft for CRM Data Migrations

In the previous blog I mentioned that this cannot be done as the fields doesn’t get displayed via the Kingsway tool. There is nothing wrong with it when you think about the scenario as the modified-on field should actually be set to the time a record has been modified in CRM. This would be set to the time when the record is updated via the web services.

However in most of the data migration the client needs asks the data migration team to set the modified on time to the last updated time of the record in their previous system. This is more important to them than the actual created on time of the record in the previous system.

Now the problem would be we cannot set this to modified-on time in CRM via the tool. We can set this time to the created on time via the tool and most of the client would be agreeing to it (Please note when you do this you cannot set the actual created on time of the record). Also please note that you have to set the updated on date to overridecreatedon field in the Kingsway soft tool. (You should be having a security role which has permission to update this field)

But some clients are adamant that they want to see the same date time value in the modified on time. This can be achieved by a simple plugin.

The plugin has to be registered in the pre create of the entity that you are migrating the data to. It should be having the following code. After this is set your modified on time would be set to the actual updated time from the previous system. I was greatly helped by the following blog post to get an idea about this.




if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
                //get the entity from the input parameters
                Entity entity = (Entity)context.InputParameters["Target"];

                if (entity.Attributes.Contains("createdon") && entity["createdon"] != null)
                {
                    //assign the modifiedon time to the created time for dm
                    entity["modifiedon"] = entity["createdon"];
                }
            }

No comments:

Post a Comment

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...