More in this section

Forums / Developing with Sitefinity / ExpirationDate is NULL for Custom Content Module.

ExpirationDate is NULL for Custom Content Module.

2 posts, 0 answered
  1. Erik
    Erik avatar
    62 posts
    02 May 2011
    20 Jun 2012
    Link to this post
    I created a custom module using the module builder. I am trying to search for all of the published items for its type. The problem is that the ExpirationDate is always null. Here is the code I use to retrieve the items:

    var query = " Visible = true AND Status = Live AND PublicationDate <= DateTime.UtcNow AND (!ExpirationDate.HasValue OR ExpirationDate > DateTime.UtcNow) ";
    var items = App.WorkWith().AnyContentItem(type).Manager.GetItems(type, query, string.Empty, 0, 0);

    I generated the type with TypeResolutionService.ResolveType(...); Items come back but their ExpirationDate is null. Items that have an expiration date before the current date also come back and I don't want them too.
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    30 Oct 2017
    21 Jun 2012
    Link to this post
    Hello Erik,

    As mentioned in the other forum thread on a similar topic, the ExpirationDate property will be set to a certain value when the item is scheduled for Unpublish. However you can handle this in the filter as well. Please find below the default implementation for the Published() fluent filter:
    return (item) =>    item.Visible == true &&
                                        item.Status == ContentLifecycleStatus.Live &&
                                        item.PublicationDate <= DateTime.UtcNow &&
                                        (item.ExpirationDate == null || item.ExpirationDate > DateTime.UtcNow);

    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered