Geeks With Blogs
CMD Programming with a sawzall

I figured I would share an interesting thing I discovered today that appears to be amazingly undocumented.

If you use U2U CAML Query Builder to build your CAML queries it creates queries that look like this when querying against columns of type 'User':

 <property name="QueryOverride" type="string">
      <![CDATA[<Where><Eq><FieldRef Name='Author' /><Value Type='User'>[Me]</Value></Eq></Where>]]>
 </property>

And that query will not work.  It will return zero results.

So queries like this:

<property name="QueryOverride" type="string">
          <![CDATA[<Where><Eq><FieldRef Name="Index_x0020_Number" /><Value Type="Number">7</Value></Eq></Where>]]>
</property>

and this:


<property name="QueryOverride" type="string">
          <![CDATA[<Where><Contains><FieldRef Name="Title" /><Value Type="Text">testapp</Value></Contains></Where>]]>
</property>

will work fine but using the token '[me]' like it is used everywhere else in MOSS will not work.

The solution ends up being this:

<property name="QueryOverride" type="string">
        <![CDATA[<Where><Eq><FieldRef Name='Author'  /><Value Type="User"><UserID /></Value></Eq></Where>]]>
</property>

 

Posted on Monday, December 15, 2008 11:46 AM MOSS 2007 , Programming (General) | Back to top


Comments on this post: CQWP, QueryOverride and Columns of type 'User'

# re: CQWP, QueryOverride and Columns of type 'User'
Requesting Gravatar...
Thank you, was looking for a fix for ages
Left by Ari Gold on Mar 27, 2009 4:39 AM

# re: CQWP, QueryOverride and Columns of type 'User'
Requesting Gravatar...
Thank you so much..it was very helpful
Left by Sanjay on Nov 26, 2009 11:30 PM

# re: CQWP, QueryOverride and Columns of type 'User'
Requesting Gravatar...
I tried using this filter for "TicketContact" which is a custom field of Type "Person or Group"

<property name="QueryOverride" type="string">
<![CDATA[<Where><Eq><FieldRef Name='TicketContact' /><Value Type="User"><UserID /></Value></Eq></Where>]]>
</property>

but it does not return anything
Left by gautam jaiswal on Feb 05, 2010 11:08 AM

# re: CQWP, QueryOverride and Columns of type 'User'
Requesting Gravatar...
I have added the query to pull user tasks in a site collection.
The issue is
"There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again."

I have used the query:
<![CDATA[<Or><Eq><FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID/></Value></Eq><Membership Type="CurrentUserGroups"><FieldRef Name="AssignedTo"/></Membership></Or>]]>
Left by Praveen on Nov 04, 2011 6:12 AM

Your comment:
 (will show your gravatar)


Copyright © CMD | Powered by: GeeksWithBlogs.net