Try our conversational search powered by Generative AI!

Override start published date and changed date when migrating from another CMS to Optimizely CMS 12

Vote:
 

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?

#297968
Mar 09, 2023 10:52
Vote:
 

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;

            contentRepository.Save(myPage, EPiServer.DataAccess.SaveAction.Publish);
#297972
Edited, Mar 09, 2023 11:54
Vote:
 

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.

#298051
Mar 10, 2023 8:51
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.