web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update modifiedon field on data migration

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    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

  • balakrishna uppala Profile Picture
    570 on at

    Hi Eswaranathan,

    Yes, we can do the overriddencreatedon for createdon.

    My issue is with updating modifiedon.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

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

  • Verified answer
    Piotr Kalwasinski Profile Picture
    240 on at
  • Raviteja Reddy Profile Picture
    280 on at

    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
    David Jennaway Profile Picture
    14,065 on at

    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

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

  • balakrishna uppala Profile Picture
    570 on at

    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?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans