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;
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):
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 !
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: http://world.episerver.com/forum/developer-forum/-EPiServer-75-CMS/Thread-Container/2014/1/Get-latest-page-version-saved-not-published/