I have item with publishing restrictions. After apply restriction for item I see that in Livetime section Valid From and Valid To fields was set. It's ok.

But when I'm trying to get item by id:


where Sitecore.Context.Database is master - I couldn't get this item, but I can search item by id in Content Editor search.

When I will remove publishing restrictions and clear Valid From and Valid To fields - I will receive my item.

Could you explain me:

How Valid From and Valid To fields affect get item from master db?

Sitecore 8.1 Update-3


1 Answer 1


This has to do with how the data providers work in Sitecore and as mentioned in the linked SO post above, is useful for distinguishing "preview" modes.

If you enable what in Sitecore is known as "Live Mode", this is what it does.

From LiveMode.config.disabled in a vanilla Sitecore installation:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <site name="website">
        <patch:attribute name="database">master</patch:attribute>
        <patch:attribute name="filterItems">true</patch:attribute>
        <patch:attribute name="enableWorkflow">true</patch:attribute>


This setting specifies whether Live Mode will filter out items that have publishing restrictions.

This is what is filtering your items in your example. Valid From and Valid To are publishing restrictions.

enableWorkflow While not in your example, Sitecore would also return NULL for items that are in a workflow state that is not final. This setting toggles that behaviour.

What I normally do locally, is have 2 sites configured, pointing to my "master" database. One which is "normal" and one running true Live Mode.

You could do the same, or just add the above 2 attributes to your site definition.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.