Hi, I'm having trouble deleting a version of page.
First I create a page programatically like this:
PageData page = DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, "MyPageType"); page.PageName = "MyPage"; DataFactory.Instance.Save(page, EPiServer.DataAccess.SaveAction.Save, AccessLevel.NoAccess);
That works fine. Then I want to change a property of my created page and as I understand it you need to make clone of the page in order to make it writeable.
PageData myClonedPage = myOriginalPage.CreateWritableClone(); myClonedPage.PageName = "MyNewPageName"; DataFactory.Instance.Save(myClonedPage, EPiServer.DataAccess.SaveAction.Save, AccessLevel.NoAccess);
This creates a new version of the page. Now I want to delete the original version and I try to do it like this. I get no error message but the page version does not get deleted.
PageVersionCollection pvc = DataFactory.Instance.ListVersions(myOriginalPage.PageLink); DataFactory.Instance.DeleteVersion(pvc.ID, AccessLevel.NoAccess);
Is the problem that I try to delete the Masterversion or what? Is there another way to change a created page programtically?
I hate to bump my own thread but I really need someone to point me in the right direction with this issue.
Do you have to save the page before setting the property? if not then you can set the property before you save the page and you'll end up with only one version.