Hi, let's say im going to migrate a page from SharePoint CMS to Optimizely CMS. The metadata from the SharePoint CMS page has a published date and modified date. Am I able to override published date and changed date programmatically in Optimizely CMS with the dates from the old CMS?
Yes this is possible to do just set the StartPublish or PublishDate on your writeable clone and save.
var parent = ContentReference.StartPage;
IContentRepository contentRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
PageData myPage = contentRepository.GetDefault<StandardPage>(parent);
myPage.PageName = "My new page";
myPage.StartPublish = DateTime.Now;
myPage.Created = DateTime.Now;
You may use ForceCurrent Version for migration in SaveAction event, so while you re-run the migration and update page, it will not create multiple version in CMS.