Standard Values and Oracle NULL

Posted 09/18/2013 by vconcepcion

Came across an interesting bug related to Standard Values when using Sitecore with the Oracle Data Provider.  The issue can be easily reproduced by creating a template field with a non-empty Standard Value, such as a checkbox that is enabled by default.

Checkbox field with Standard Value

In the above example, if you uncheck the "Inherit from parent" field and save the item, the checkbox will actually revert itself to the checked state.  This is because Oracle will store a field value of empty string as null, which Sitecore in turn handles by returning the field's Standard Value.  Note that this applies to any field type which a user may set to an empty value.

This has been registered as a bug for the current release of Sitecore, but in the meantime two possible workarounds are:

  1. Use a Branch Template to set the default value of a field.
  2. Train CMS users to use a non-empty placeholder value instead of an empty string.  For the checkbox example, this requires switching the field type to a text box and establishing a convention by which users enter "0" to indicate an unchecked state.

Text field with placeholder value

We ended up using the latter workaround since we use Standard Values on quite a number of our templates and didn't want to create a Branch Template for each one. Also, Branch Templates would not support the "Reset Fields" feature which reverts a field to its Standard Value.

Share:

Archive

Syndication