Introduction
Dataverse (formerly the Common Data Service) provides powerful capabilities for managing data within Microsoft Power Platform. One of the important metadata fields in every table is CreatedOn (or createdon in the backend), which stores the date and time when a record was created.
However, what if you need to update or backdate the CreatedOn field for existing records? Maybe you’re migrating data from an external system or correcting historical records due to a business requirement. This scenario is common but not straightforward due to platform constraints.
In this blog, we’ll walk you through a real-world scenario, the challenge with modifying system fields like CreatedOn, and how to work around it is using plugin code.
Solution:
- First step would be to create a temporary field which will hold date time value. This field will be used to replace createdon field value. Here, I have created custom field named as “brn_createdoncopy”, which we will use for createdon date replacement.

- Next, we will create a simple plugin code, which will update createdon field with brn_createdoncopy.
public class CreatedOnMapping : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.Depth > 1)
return;
// Check that the target entity is present and is a Bank Transaction
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity entity)
{
// Get the organization service
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Check if the custom field exists and is populated
tracer.Trace(entity.Id.ToString());
tracer.Trace(entity["brn_createdoncopy"].ToString());
entity["createdon"] = entity["brn_createdoncopy"];
service.Update(entity);
}
}
}
- Register Assembly using Plugin Registration tool and create Plugin step on same entity where you want to update createdon field.
- Select filtering attribute to newly created field, Keep stage to PreOperation, Execution Mode to Synchronous. User context will be user who has System Administrator role or else this plugin will get executed successfully but will not reflect createdon field value.

Test:
- Add createdon and brn_createdoncopy fields on Form for testing purpose.
- Before we change update brn_createdoncopy. Here Created On is 26/08/2024 and we are changing it to 24/08/2024 which is 2 days past.

- After we change update brn_createdoncopy, Created On is updated to 24/08/2024.

- Note that, this approach will update Modified On and Modified By to System user which can be prevented by excluding fields in plugin.
Leave a Reply