CharlZ's Blog

Ramblings about SharePoint, etc.

Fun with CAML Joins

I was working with joins using a CAML query for the first time today and I was using this document to learn about this topic:

While I was working on building my query, I kept receiving the error "Value does not fall within the expected range."  This was happening each time I tried to set value of the SPQuery.Join property.  I was following the format of the example in the article for this property.  It begins with "<Joins>", contains multiple "<Join>" nodes, and ends with "</Joins>".  It turns out that adding the "<Joins>" outer node caused the error.  I simply needed to add each of the "<Join>" nodes without wrapping them inside a "<Joins>" node.  After I had it sorted out, it made some sense to me, but it is pretty frustrating when the MSDN documentation is misleading.

This also applies to the ProjectedFields and ViewFields properties as well.

The one limitation that is problematic to me is that choice fields cannot be used as projected fields.  This forced me to redesign my choice fields as lookup fields.