Try our conversational search powered by Generative AI!

Trouble deleting a page version


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[0].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?

Thank you!


Feb 13, 2009 9:58

I hate to bump my own thread but I really need someone to point me in the right direction with this issue.

 Anyone please?

 Thank you!

Mar 03, 2009 9:00

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.

 -Kjetil Simensen

Mar 03, 2009 13:44
Yes. The initial page is created when a user fills a form. An email verification is sent out and when the user clicks the emailed verfication link I need to update a "status property".
Mar 04, 2009 9:50
* 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.