Enforce version presence

Version: 10.4

In Sitecore, you can have different versions of an item, for example, different versions of an image or versions of an item in a different language. When an item doesn't have any item versions, and you try to fetch a version of that item, instead of returning NULL, Sitecore returns the non-versioned item. To change this behavior, and enforce the presence of a version, use the Enforce version presence feature. The feature ensures that an item version is returned only if it exists (in a database or resource). By default, enforce version presence is disabled; the setting is configured for each site separately, so it could be enabled on some and disabled on others.

You enforce version presence by first enabling it for the entire website, then configuring it for individual items. You can enable enforce version presence on individual items, or on all items based on an item template, by setting the configuration for the item or item template, respectively.

To enforce version presence:

  1. Open the website configuration file (for example, under \Website\App_Config\Sitecore.config ) and set the enforceVersionPresence attribute to true. If the enforceVersionPresence attribute is not present, you can add it manually using a configuration patch file, for example:

    RequestResponse
    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
        <sitecore>
            <sites>
                <site name="website">
                  <patch:attribute name="enforceVersionPresence">true</patch:attribute>
                </site>
            </sites>
        </sitecore>
    </configuration>
    Note

    Don't enable the enforceVersionPresence attribute on the shell or any other default site.

  2. To enforce version presence on an item or template, in the Content Editor, on the View tab, make sure that the Standard fields view is enabled.

  3. Navigate to the relevant item.

    Note

    To enable the feature for all items that are based on a certain template, apply the setting to the __Standard Values item of the template.

  4. In the Advanced section, select the Enforce Version Presence check box.

Do you have some feedback for us?

If you have suggestions for improving this article,