ExpirationDate is NULL for Custom Content Module.
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);
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);