How to find pages with an empty property?

kers
Member since: 2005
 
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
Mar 25, 2008 18:35
jo
Member since: 1996
 
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
Mar 25, 2008 18:47
steven.pap
Member since: 2007
 

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
steven.pap
Member since: 2007
 

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

#28109
Feb 20, 2009 12:35
ian.causton
Member since: 2006
 

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
Magnus Rahl
Member since: 2008
 

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