CAML Query – Obtain items past due OR due in 21 days

by oscar 8/27/2008 5:02:50 AM

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.

image

FIGURE 2 – Editing a Task on the WebPart

image

<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>

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CAML | DataViews | SharePoint Designer | WSS 3.0

Related posts

Comments

8/27/2008 4:25:36 PM

Hi,

Thanks for providing this piece of CAML. I've been facing this problem on some occasions aswell, I just fixed it in code then.

What wonders me, is how you enabled emailing.

I assume you used a FormWebPart and manipulated the XSLT, but can you provide such a piece ?

Or did you use a GridView control to do this ?

Thanks in advance,

Pascal Van Vlaenderen

Pascal Van Vlaenderen be

8/28/2008 5:52:42 AM

Hi Pascal,

If you mean "Editing", this is done through the DataView Properties window. It generates the code for you automatically.

Cheers,
Oscar

Oscar us

8/28/2008 5:18:20 PM

I indeed meant editing. I'm even stumbled why I wrote emailing. I should really investigate this further ...
Thanks for pointing me in the right direction !

Pascal Van Vlaenderen be

Add comment


 

  Country flag





Live preview

11/21/2008 3:17:38 PM

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About Me

Oscar Medina I am a SharePoint Solutions Architect based out of San Francisco, California.
You can read more about me here

E-mail me Send mail
View Oscar Medina's profile on LinkedIn

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in