I just tested the code to replace the field createdOn in two different ways:
- With a plugin with step on create pre-operation, and the createdOn was not overridden.
- Then I tried the same code but using an external application (console application) and this time the createdOn was overridden by the date defined on overriddencreatedOn.
Actually, this makes sense because this features is used to maintain historical data after records have been imported to CRM (maintain the createdOn date of the records imported).
In addition to above notes on syntax, be aware that you need a security privilege to override createdon or createdby (on the Business Management tab of Security Role). Make sure the user running your code (or whom it is impersonating) has this privilege.
Console Code snippet
Entity objLead=new Entity(“lead”);//replace lead with your entity
objLead[“overridecreatedon”]=Datetime.now;//Replace this with whatever data you want to update
Hope you find thie helpful!