Huge title but pretty much what this post is about.
To optimize your FindPagesWithCriteria, it’s good to be as specific as you can. i.e not use one criteria, get 500 hits back and then just use the top 5 out of those. Anyway, when using a PropertyDataType.Boolean and you want to get back those pages that has this set to ”false” you can’t really set the value to ”false”. Why? Because when the property is false, it has never been set which makes it null.
Let’s see the code:
PropertyCriteria crit = new PropertyCriteria{
Condition = CompareCondition.Equal,
Name = ContentPropertyStrings.Finished,
Type = PropertyDataType.Boolean,
Value = "false",
Required = true
};
The code above won’t give you any hits since there won’t be any property set to false, because those properties are null. What you need to do is what you can see below.
PropertyCriteria crit = new PropertyCriteria{
Condition = CompareCondition.Equal,
Name = ContentPropertyStrings.Finished,
Type = PropertyDataType.Boolean,
IsNull = true,
Required = true
};
An old problem but I still get this question from time to time so might aswell post it














FindPagesWithCriteria with PropertyCriteria and PropertyDataType.Boolean set to false http://is.gd/bZMQY
This comment was originally posted on Twitter
Really helpful! Thanks!
That’s exactly what I was looking for, thanks ! PropertyCriteria rulez
Thanks for this article. It really help me.