Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Update modifiedon field on data migration

Posted on by 570

Hi there,

I am doing migration from CRM 2016 on Premise to CRM 365 online using Kingswaysoft.

I am trying to update createdon/by, modifiedon/by fields.

I know it is not possible to map directly in Kingswaysoft but I read in some blogs that we can do it using Pre-Operation plugin.

I have registered the plugin on Pre-Operation on Account, populated createdon, modofiedon fields in holding fields but my plugin is not updating the modifiedon fields.

Is there any changes in latest versions of CRM to not allow to update modifiedon field from plugins as well?

CreatedOn updated with historic date but not modifiedon.

Below is my code to update

tracing.Trace("Before conditions");

if (entity.Attributes.Contains("sfaa_commsdate"))
{
craetedOn = (DateTime)entity.Attributes["sfaa_commsdate"];
tracing.Trace("craetedOn " + craetedOn);
}
if (entity.Attributes.Contains("sfaa_la"))
{
craetedBy = entity.Attributes["sfaa_la"].ToString();
tracing.Trace("craetedBy " + craetedBy);
}

if (entity.Attributes.Contains("lastonholdtime"))
{
modifiedOn = (DateTime)entity.Attributes["lastonholdtime"];
tracing.Trace("modifiedOn " + modifiedOn);
}

if(entity.Attributes.Contains("sfaa_local"))
{
modifiedBy = entity.Attributes["sfaa_local"].ToString();
tracing.Trace("modifiedBy " + modifiedBy);
}

entity["createdon"] = craetedOn;
entity["createdby"] = new EntityReference("systemuser", new Guid(craetedBy));
entity["modifiedon"] = modifiedOn; // DateTime.Now.AddYears(-3);
entity["modifiedby"] = new EntityReference("systemuser", new Guid(modifiedBy));
//entity.Attributes.Remove("modifiedon");
//entity.Attributes.Remove("modifiedby");
//entity.Attributes.Add("modifiedon", modifiedOn);
//entity.Attributes.Add("modifiedby", new EntityReference("systemuser", new Guid(modifiedBy)));
tracing.Trace("Updated the fields");

Thanks

krishna

*This post is locked for comments

  • balakrishna uppala Profile Picture
    balakrishna uppala 570 on at
    RE: Update modifiedon field on data migration

    Hi David,

    Sorry for late reply!. Yes I realized when I migrated i didn't disabled plugins and workflows.

    Now I have disables all plugins still in audit I can see two events happening

    1. Create

    2. Update - It is just updating statecode & statuscode from Active to Active

    In the data mapping, I am setting State, Status as well. If I set these, will it perform an update operation seperately?

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Update modifiedon field on data migration

    In addition to above suggestions, take a look here as well- rajeevpentyala.com/.../set-created-on-created-by-modified-on-modified-by-fields-using-sdk-data-import-plug-in-dynamics-365

    Hope this helps.

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Update modifiedon field on data migration

    Is the "sfaa_local" attribute a string datatype that contains a Guid, or some other datatype. Only a string datatype that contains a Guid would work with the code that you have, so if it's a different datatype, this may be the problem.

    It's also worth enabling auditing and checking what is happening. If your plugin is only registered on a create, you may have another update happening afterwards, which would override your changes

  • Raviteja Reddy Profile Picture
    Raviteja Reddy 280 on at
    RE: Update modifiedon field on data migration

    I'd suggest to create a custom date field something like "Modified On CRM16" and migrate the Modified date into it, this can be used for reporting existing/migrated data. The future records created will still use system ModifiedOn or sync it with the new Modified On field using a business rule. I will also recommend to add a flag to differentiate Migrated/New data which can be used to create processes which will differentiate  new/Migrated records.    

  • Verified answer
    Piotr Kalwasinski Profile Picture
    Piotr Kalwasinski 240 on at
    RE: Update modifiedon field on data migration

    Hi,

    This operation indeed seems possible via the pre-operation event:

    https://community.dynamics.com/crm/b/crmchap/archive/2018/04/22/override-the-modified-on-field-value-when-reassigning-resolved-cases-dynamics-365-for-customer-service

    Piotr

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Update modifiedon field on data migration

    you should be able to update them. Did you debug the code to see what do you see in the final "Entity" object?

  • balakrishna uppala Profile Picture
    balakrishna uppala 570 on at
    RE: Update modifiedon field on data migration

    Hi Eswaranathan,

    Yes, we can do the overriddencreatedon for createdon.

    My issue is with updating modifiedon.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Update modifiedon field on data migration

    Hi

    If you set the Created On date to overriddencreatedon field, CRM will then set the Created On field value. You do not need a plugin for this

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans