Determine If A Content Item Is Expired In Code

  • Updated
Description

Determine If A Content Item Is Expired In Code

Solution

If you set any/multiple content item(s) to expired and want to check in code which items are expired, just do the below:

You can use IPublishedStateAssessor to check a catalog entry is published or not like this:

var publishedStateAssessor = ServiceLocator.Current.GetInstance<IPublishedStateAssessor>();

var isPublished = publishedStateAssessor.IsPublished(entryContent, PublishedStateCondition.None);

 

The variable "isPublished" now can be used to determine with code, what content items are expired or not.