Try our conversational search powered by Generative AI!

Saving an already-published page with pending changes


Dear Community,

I wish to perform some changes to pages that are already published and have pending changes (mainly because editors changed the content without publishing them again).

I read this great documentation about the enumeration SaveAction. I ended up using the code proposed in the example of that article:

PageData pd = GetPage(CurrentPage.PageLink).CreateWritableClone();
pd["PageName"] = "New Page Name";
SaveAction action = SaveAction.None;

if (pd.CheckPublishedStatus(PagePublishedStatus.PublishedIgnoreDates))
    action = SaveAction.Publish;
    action = SaveAction.Save;
action = action | SaveAction.ForceCurrentVersion;
Locate.ContentRepository().Save(pd, action, AccessLevel.NoAccess);

The thing is with the code above, pages that are published and still have pending changes are not modified. I tried to play with the other values of the enumeration but unfortunately, I always fall in one of the two cases above (for published pages with pending changes):

  • The modifications I would like to introduce programmatically are not applied, or
  • the modifications I would like to introduce programmatically replace the pending content.

Ideally, I would like to add some changes programmatically to the pending changes, not overwrite the pending changes.

Do you know if EPiServer is able to perform such modifications ?

Many thanks !

Apr 20, 2017 8:27

By default when you get a page by Id, you get the latest published version, not the latest saved version. That may be your problem. 

Here's a guide how to get a specific version of a page:

Apr 21, 2017 11:56
* 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.