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

Vote:
 

Hi,

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?

#122813
Jun 15, 2015 16:47
Vote:
 

Hi,

It was one of the breakng change in EPiServer 8.

The reason is described in:

http://world.episerver.com/documentation/Items/Upgrading/EPiServer-CMS/8/Breaking-changes/

in section Saving published content with save action Save and ForceCurrentVersion

#122814
Jun 15, 2015 18:56
Vote:
 

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).

BR,

Marija

#122815
Jun 15, 2015 19:04
Vote:
 

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.

#122817
Edited, Jun 15, 2015 21:59
Vote:
 
<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>
#122826
Jun 16, 2015 10:37
Vote:
 
<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>
#122828
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.