Was working on getting Tasks assigned to a user on a custom DataViewWebPart titled “My Critical Tasks”. It is easy to obtain past due items, but sometimes you need both Past Due and due in X number of days. I was battling (as with anything SharePoint) with this CAML query, but finally got this one to work.
On my XSL I render an indicator image based on the date each Task has, looks something like this (FIGURE 1). I enabled editing as well, so a user can edit the status of the task right from the home page and modify the Due Date, Status, and Notes if needed!
FIGURE 1 – Tasks shown based on the User that is currently logged onto the MOSS Site.
FIGURE 2 – Editing a Task on the WebPart
<Query>
<Where>
<And>
<And>
<And>
<Geq>
<FieldRef Name='DueDate' />
<Value Type='DateTime'>
<Today OffsetDays='-21' />
</Value>
</Geq>
<Eq>
<FieldRef Name='AssignedTo' />
<Value Type='Integer'><UserID/></Value>
</Eq>
</And>
<Neq><FieldRef Name='Status'/><Value Type='Text'>Completed</Value></Neq>
</And>
<Or>
<IsNotNull>
<FieldRef Name='Related_x0020_Event'/>
</IsNotNull>
<IsNotNull>
<FieldRef Name='Related_x0020_Course'/>
</IsNotNull>
</Or>
</And>
</Where>
<OrderBy>
<FieldRef Name='DueDate' Ascending='True' />
</OrderBy>
</Query>