kenticokentico-12kentico-mvc

How can I override DocumentCreatedWhen and DocumentModifiedWhen while using Kentico Import Toolkit?


I've created a number of .iprofile files to import pages from a legacy WebForms site into the "Content-Only" versions on a new MVC site. This works great except that it ignores the mapping for DocumentCreatedWhen and DocumentModifiedWhen. Each time the import occurs without errors but the Created and Modified dates in the MVC site are the date/time of the import, not the original date and time.

I've tried using the GUI version of the Import Toolkit and the command-line version, I've verified that there are mapping elements in the .iprofile files for DocumentCreatedWhen and DocumentModifiedWhen, like so:

<mapping target="documentcreatedwhen" source="DocumentCreatedWhen" />
<mapping target="documentmodifiedwhen" source="DocumentModifiedWhen" />

Does this work with the Kentico Import Toolkit or will I need to use a different mechanism?

Edited title to use correct field names...


Solution

  • Unfortunately, both values are set when an object is created and/or modified and both these properties have internal setters so basically from your perspective are just read-only. Onehack around it would be to change system clock as they rely on DateTime.Now; and another would be to actually convince framework with your own implementation of DateTime

    Last and easiest approach would be to import data and than run SQL to adjust modified fields directly.