Try our conversational search powered by Generative AI!

How to find pages with an empty property?

Vote:
 
How do I make a search for all pages where a property hasn't been set? Our website contains 16000+ pages with a propery named infoOwner, only recently it has been descided to make this property mandatory, so my problem is now to generate a list with all the pages where the property infoOwner hasn't been set or is empty. I've tried making a FindPagesWithCriteria search, with the following code: PropertyCriteriaCollection col = new PropertyCriteriaCollection(); PropertyCriteria criteria = new PropertyCriteria(); criteria.Name = "infoOwner"; criteria.Value = string.Empty; criteria.Condition = EPiServer.Filters.CompareCondition.Equal; col.Add(criteria); PageDataCollection pages = EPiServer.Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.RootPage,col); and PropertyCriteriaCollection col = new PropertyCriteriaCollection(); PropertyCriteria criteria = new PropertyCriteria(); criteria.Name = "infoOwner"; criteria.Value = null; criteria.Condition = EPiServer.Filters.CompareCondition.Equal; col.Add(criteria); PageDataCollection pages = EPiServer.Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.RootPage,col); Both end up with no result. Can anyone help?
#13067
Jun 13, 2007 10:33
Vote:
 
Hi Kenneth! Try using the PropertyCriteria.IsNull instead, like: PropertyCriteriaCollection col = new PropertyCriteriaCollection(); PropertyCriteria criteria = new PropertyCriteria(); criteria.Name = "infoOwner"; criteria.IsNull = true; criteria.Condition = EPiServer.Filters.CompareCondition.Equal; col.Add(criteria); PageDataCollection pages = EPiServer.Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.RootPage,col); Regards, Johan Olofsson EPiServer AB
#15341
Jun 14, 2007 13:55
Vote:
 

those 3 criterea won't work fo an epi property i.e 'PageName' , what's the best way to FPWC and passing it a generic request to ret all pages. in my mind if pagename is there it should return it, then I can filter on my custom needs

FilterCriteria.IsNull = true;

FilterCriteria.Name = "PageName";

 

#28108
Feb 20, 2009 12:32
Vote:
 

what about rather checking that it's not null.. on the epi property pagename

#28109
Feb 20, 2009 12:35
Vote:
 

hi,

If you just require a list of the pages, do you need to go through EPi at all?

A piece of T-sql might be a better route to get this information.

Ian

#28236
Feb 26, 2009 14:28
Vote:
 

I was working on a similar issue yesterday (before reading this thread) and never got the hang of the workings of IsNull. I ended up getting all pages (by searching for a PageTypeID greater than 0) and looping through/filtering the pages. I suppose you're only doing this once to the performance penalty of such an approach is probably neglible.

Edit: Oh, this is probably even easier by using the DataFactory.Instance.GetDescendents if you are running CMS 5 R2

#28241
Edited, Feb 27, 2009 7:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.