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!

Bool properties in EPiServer 7


Earlier a bool property has never been false, only null or true.

Is this still so and is the best practise to use "public virtual bool" or nullable bool?

Asking because I'm getting some weird behaviour when saving a page programmatically.

Jan 03, 2013 15:37

It is still so under the covers but you can use public virtual bool and null will be false, so you really don't have to care about that behaviour anymore.

There is a bug regarding saving pages programmatically where it may pick up an older version and apply the changes to instead of the latest version, this happen when you get the published page and programmatically make changes to it and then publish.  This bug is not visible in edit mode since it has custom code to pick the latest version that does not have this bug. For now you will have to contact support to get a fix for that if that is the problem you are facing.

Jan 04, 2013 9:19

Ah, that bug description fits like a glove to the probs I'm seeing. Will contact support. Thanks!

Jan 04, 2013 9:24

The answer I'm getting from support is that no fix or patch will be available and that the problem will persist until the next relasese (q2 / q3). This is clearly unacceptable and puts all our EPi7-projects on hold, or even worse, in crisis mode. We will take this upstairs at EPi.

Jan 09, 2013 10:50

Per, could SaveAction.ForceNewVersion be used as a workaround for that bug? Seems like something I ran into a couple of days ago and in that case it worked.

Jan 09, 2013 11:08

Hi Johan,

We do realize that this is a severe problem that needs to be adressed sooner rather than later. The current resolution of the bug unfortunately makes it unsuitable to be distributed as a hotfix/patch but we are looking into an alternative way of fixing it. We cannot give any date for when this will be available but you should not need to wait until Q2. In the mean time you can use the workaround suggested by Joel.

Jan 09, 2013 15:19

So can I just replace SaveAction.Publish with SaveAction.ForceNewVersion in my code or do I need to use something like "SaveAction.Publish | SaveAction.ForceNewVersion" for all calls DataFactory.Instance.Save()? The calls might handle both existing and new PageData objects.

Edit: Or do I need to change my code so that it uses different save actions for new or existing pages?

Edited, Jan 09, 2013 15:49

You need both flags for it to work, so SaveAction.Publish | SaveAction.ForceNewVersion

Jan 09, 2013 16:03

Great! Thanks! Haven't seen the previous symptoms anymore after changing.

Can EPi post some more info here on which SaveActions that can trigger the bug?

A direct link for the bug list that works would also do it if it has that info.

Jan 10, 2013 9:46

Bug #92742 : When saving and publishing an existing page with code some properties previously published values are reset

When saving an existing page with DataFactory.Save() some properties previously published are reset. The bug is in the code that selects a version if no parameter is saying which version to update. So if you load a new version of a page yourself and then save it, or create a new page or use ForceNewVersion/ForceCurrentVersion you will not enter the code that determines which version to update (possible workarounds).

 Steps to Reproduce:

  • Install a plain vanilla Alloy demo site. Add two string properties to the StandardPage pagetype.

[Display(GroupName = SystemTabNames.Content)]

public virtual string String1 { get; set; } 

[Display(GroupName = SystemTabNames.Content)]

public virtual string String2 { get; set; }

  • Go to Edit Mode and set the value of String1 of any given StandardPage and publish.
  • Execute the code below and set the value of String2.
  • In edit mode remove String1  value and publish
  • Execute the code again
  • In edit see that the old value for String1 value has returned.

var reference = new ContentReference(6); // Insert relevant page id

var page = DataFactory.Instance.Get<StandardPage>(reference).CreateWritableClone() as StandardPage;

page.String2 = "string 2";

DataFactory.Instance.Save(page, SaveAction.Publish, AccessLevel.NoAccess);

Jan 11, 2013 11:56
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.