Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Error after upgrade to 8.5+ "Using SaveAction.Save + SaveAction.ForceCurrentVersion on published content is not allowed"



We have been using the code that was working quite well:

_contentRepository.Save(clone, SaveAction.Save | SaveAction.ForceCurrentVersion, AccessLevel.NoAccess);

However, after upgrade, this gives the error: "EPiServer.Core.EPiServerException: Using SaveAction.Save + SaveAction.ForceCurrentVersion on published content is not allowed". 

Is there a reason why the behavior was changed or is this a bug?

Jun 15, 2015 16:47


It was one of the breakng change in EPiServer 8.

The reason is described in:

in section Saving published content with save action Save and ForceCurrentVersion

Jun 15, 2015 18:56

Thx a lot, Grzegorz, I didn't manage to find this.

Do you understand this part: "You are supposed to pass in either Save on versions or Publish to modify a published content without changing status."

I can't publish, since I don't want to change the ChangedBy value (publish changes it). When I save, the new version is not forced, so the page is not changed.

I tried using SaveAction.Publish | SaveAction.SkipSetCommonDraft (since I've noticed the latter is new to SaveAction), however, this works as it should when I first modify the page, but when I do the same the second time, I see the previously published page (instead of the first published one).



Jun 15, 2015 19:04

Ah no, it's been a while since I wrote that code. The combination Save and ForceCurrentVersion does change the ChangedBy, but at least it doesn't change Changed. Then, in on publishing event, I set a RealChangedBy value (this is not called with Save | ForceCurrentVersion, so that worked well).

Now, when I switched to Published, the event is called and RealChangedBy is set anyways. So, I need a way to know if the page is "really" changed. I am now checking the following:

((SaveContentEventArgs)e).Action != SaveAction.Publish | SaveAction.SkipSetCommonDraft,

I'll dig deeper if EPi uses the same combination elsewhere.

Edited, Jun 15, 2015 21:59
<p>I guess this doesn't help with your problem Marija, but it may be good to know that there's a extension method called page.GetForceCurrentVersionSaveAction();. With that you don't have to check if a page is published etc when resaving.</p>
Jun 16, 2015 10:37
<p>Hi, Erik,</p> <p>Thx, it's not what I need, but still good to know.</p> <p>For now, I took the following approach - when saving, I save with&nbsp;<span>SaveAction.Publish | SaveAction.SkipSetCommonDraft. That doesn't change the&nbsp;Changed date value, which is great.</span></p> <p><span>Then, in Publishing event, I check if SaveAction is different from that combination and set my own RealChangedBy, if so.</span></p> <p><span>It looks like it's working, for now :)</span></p>
Jun 16, 2015 11:12
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.