<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Peter Gerritsen&#039;s blog &#187; CAML</title>
	<atom:link href="http://blog.petergerritsen.nl/tag/caml/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.petergerritsen.nl</link>
	<description>about .Net and SharePoint development</description>
	<lastBuildDate>Wed, 28 Jul 2010 08:28:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Retrieving Tasks assigned to users or one of their groups</title>
		<link>http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 16:55:08 +0000</pubDate>
		<dc:creator>Peter Gerritsen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/</guid>
		<description><![CDATA[Sometimes you want to retrieve all tasks that are assigned to a user or to one of the SharePoint groups the user is a member of. This quite easy to accomplish through generation of a CAML query. Just create an Or statement for tasks assigned to the user and loop through all of the groups in the SPUser [...]<p><a href="http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/">Retrieving Tasks assigned to users or one of their groups</a> is a post from: <a href="http://blog.petergerritsen.nl">Peter Gerritsen&#039;s blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to retrieve all tasks that are assigned to a user or to one of the SharePoint groups the user is a member of. This quite easy to accomplish through generation of a CAML query.</p>
<p>Just create an Or statement for tasks assigned to the user and loop through all of the groups in the SPUser object to add those to the query.</p>
<p>The resulting query will look like this:</p>
<pre class="brush: xml">
&lt;where&gt;
&lt;or&gt;
&lt;eq&gt;
&lt;fieldRef Name=&#039;AssignedTo&#039;/&gt;
&lt;value Type=&#039;User&#039;&gt;Piet van Tul&lt;/value&gt;
&lt;/eq&gt;
&lt;eq&gt;
&lt;fieldRef Name=&#039;AssignedTo&#039;/&gt;
&lt;value Type=&#039;User&#039;&gt;Region Controllers&lt;/value&gt;
&lt;/eq&gt;
&lt;eq&gt;
&lt;fieldRef Name=&#039;AssignedTo&#039;/&gt;
&lt;value Type=&#039;User&#039;&gt;Accounting department&lt;/value&gt;
&lt;/eq&gt;
&lt;/or&gt;
&lt;where&gt;
</pre>
<p>By using this query in the QueryOverride of a Content Query Web Part you have all the power of a Content Query combined with the power of query generation.</p>
<p>EDIT: My collegue Wouter Lemaire pointed out that you can only specify 2 terms per Or or And element. So the above CAML could give some unexpected results.</p>
<!-- RO Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Twitter"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/twitter.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Twitter" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to Twitter" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups&#038;c=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/" title="Add 'Retrieving Tasks assigned to users or one of their groups' to MySpace"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/myspace.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to MySpace" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to MySpace" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/&#038;title=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Del.icio.us"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/delicious.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Del.icio.us" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to Del.icio.us" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&#038;url=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/&#038;title=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups" title="Add 'Retrieving Tasks assigned to users or one of their groups' to digg"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/digg.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to digg" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to digg" /></a><br /><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/&#038;t=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups" title="Add 'Retrieving Tasks assigned to users or one of their groups' to FaceBook"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/facebook.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to FaceBook" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to FaceBook" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Technorati"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/technorati.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Technorati" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to Technorati" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/&#038;title=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Stumble Upon"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/stumbleupon.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Stumble Upon" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to Stumble Upon" /></a><a  class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&#038;output=popup&#038;bkmk=http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/&#038;title=Retrieving+Tasks+assigned+to+users+or+one+of+their+groups" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Google Bookmarks"><img src="http://blog.petergerritsen.nl/wp-content/plugins/ro-social-bookmarks/google.png" title="Add 'Retrieving Tasks assigned to users or one of their groups' to Google Bookmarks" alt="Add 'Retrieving Tasks assigned to users or one of their groups' to Google Bookmarks" /></a></div>
<!-- RO Social Bookmarks END --><p><a  href="http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/">Retrieving Tasks assigned to users or one of their groups</a> is a post from: <a  href="http://blog.petergerritsen.nl">Peter Gerritsen&#039;s blog</a></p>
<div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.petergerritsen.nl%2F2009%2F02%2F03%2Fretrieving-tasks-assigned-to-users-or-one-of-their-groups%2F&amp;layout=standard&amp;show_faces=false&amp;width=320&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:320px;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://blog.petergerritsen.nl/2009/02/03/retrieving-tasks-assigned-to-users-or-one-of-their-groups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
