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

Extended Content Query WebPart Project - Calendar Rollup enhanced functionality

by Oscar 3/10/2008 3:51:00 AM

[UPDATE] - I am almost done with this WebPart and look forward to sharing some screenshots! The ability to view recurring events using the CQWP is a definite hit!  More to come :)


Kind of a short post, but thought it would be nice to share with everyone!


I am working on an enhanced CQWP version.  The goal of this WebPart is to provide a piece of functionality that the out of the box one currently lacks.  This functionality applies when you are rolling up Calendar Events List Type.

The Business Requirement
There is a need to view recurring events when rolling up Calendar Events.  Say you have an event called "Weekly Status Meeting", and you have configured this event to be 'recurring'.  If you browse the Calendar View, you will see this event on the day you have selected for each week.

OOTB Content Query WebPart Funtionality 

Currently, if you do a Calendar Event rollup using the CQWP and you have a recurring event, the WebPart will only show you the parent event in that series.  Some people have expressed the desire to show all of the events for that particular calendar item.


My Vision

I envision the extending from the ContentByQueryWebPart, and making sure all other functionality is still there.  I am thinking of simply creating a custom ToolPart that allows for the additional configuration.

Other functionality I will make configurable via the ToolPart is:
- Ability to configure the XSL files used to render it,
- Ability to override the CommonViewFields
- Ability to override the Query being used.

Let me know if you or your clients are interested in any additional functionality :)

Stay tuned for an update on this project soon!

Cheers,
Oscar 

Currently rated 2.6 by 10 people

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

Tags: ,

MOSS 2007 | CAML | CQWP

Creating Application Pages (_layouts) in MOSS 2007 - How to do rapid development using Form Field Controls

by Oscar 1/29/2008 4:22:00 PM

As you may or may not know, there are thousands of ways to accomplish development and customization tasks in MOSS 2007 and WSS 3.0.

At one point or another, as a MOSS Consultant, you will be faced with the task of creating custom application pages.  If you have an extensive web application development experience (much like I do), you will first think of using your web application techniques when faced with this task.  However, there are better and faster ways of accomplishing customization tasks around SharePoint. 

Today I will walk you through one of those scenarios where it would make sense to completely use your typical web application skills and techniques, then show you how to do it the MOSS way!


Scenario


You are creating a custom Site Provisioning Tool for MOSS 2007, and want to allow users to enter specific information so that the new site is created.  Once the site is created, you want to add an entry in a SharePoint List to track all the sites that have been created, and maybe if you are motivated create some custom views on the List to view by Region :) 

Solution


For example, I created some fields on my page that map to the fields on a SharePoint List to track newly created project sites on a List called Projects

This is what the page looks like when browsing to it.

clip_image001[4]

FIGURE 1 - Shows the custom site provisioning application page with all the form field controls rendered


The table below shows you the actual field type used for each field on the form.
SharePoint List Fields

Field Label Field Type
Project Title Text Field
IT Owner Person or Group
IT Group Choice Menu
Region Choice Menu


The table below shows you what out of the box SharePoint Form Controls you will use

Field Types and corresponding Field Controls used on ASPX page

Field Type Control Used
Project Title - Title FormField
IT Owner PeoplePicker
IT Group FormField
Region FormField

So here is the interesting part on this blog entry!

TIP: Throughout the various Application Pages on MOSS, there are samples of how the FormField is used.  Look around, you will be amazed what you can learn just by firing up VS 2005 and viewing the code for these pages! 

Rendering the Region Field (Choice) 

Our task here is to render the Region Field which is a Choice Menu on the SharePoint List. 

The Most Obvious Way of Populating the Choice Field
Now, typically, to render the drop down menu and populate it, you would probably do the following:

a) Drag a DropDownList Control on to the page
b) Wire an event handler on the page load event, and then query the SharePoint List using CAML
c) Iterate through the results and populate the DropDownList

The Rapid Method of populating the Choice Field

a) got to your page code and type code so that you can add a FormField Controls as such

clip_image001[4]

FIGURE 2 - Shows you how you can add an out of the box FormField, set its properties so it gets wired to the appropriate column on the SharePoint List 

NOTE: The FieldName should be the same as the one specified on the List
b) Wire the FormFields's OnInit event handler - this is where we are going to tell the FormField what List we are inserting data into.
c) Write code to get a handle on the List - I used a page global variable and set its value  on OnPreInit event
d) On the FormField's OnInit handler, specify the ListName property

And that's it!  Now if you browse to the aspx application page, you should see the DropDownList populated!


Rendering the IT Owner Field (PeoplePicker)


Have you ever wanted to use that nice User Picker Control that you see on various WSS/MOSS pages?  You can!

I dropped the People Picker onto my ASPX custom application page like so:

clip_image001

FIGURE 3 - How to specify a PeopleEditor Control in a declarative manner

To obtain the values the user has selected, you need to do something similar to my code-behid page below.  Here I am capturing the value (using PickerEntity Class), and inserting a new list item on my SharePoint List.

clip_image001[5]

FIGURE 4 - Shows you how to obtain or capture the values entered in the PeopleEditor Control.


TIP: One more thing I would like to point out in the code on Figure 4.  I am also inserting a value in a Hyperlink or Picture Field Type.  You will notice that after putting the url value, i have an additional piece of information, that is the link label! in this case, 'Go To Site'.  This is how it looks on the SharePoint List

clip_image001[7]

FIGURE 5 - Shows how the link label looks based on the code used on Figure 4 to programmatically populate the Hyperlink or Picture Field Type.


I hope this information is useful to you at some point!

Enjoy,
Oscar

Currently rated 1.9 by 8 people

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

Tags:

WSS 3.0 | MOSS 2007 | CAML

Calculated Columns - Displaying Images

by oscar 12/1/2007 12:51:00 PM

Recently, I was working on a project that required the  creation of an IT Project Management Site Template.  I thought, hmm, pretty straight forward, but wait, I ran into an issue that I am positive, could have been solved in other ways (List Event Handler)

The requirement was to display an image based on a certain condition, and this condition had to do with lookup of other List Column values. 

If you want to display images for a calculated column here are the steps you need to take:

  1. Modify the FLDTYPES.XML file(or make a copy of it!)
  2. Search for the field definition "Calculated"
  3. On the default rendering pattern, paste the following

    <Switch>
    <Expr>
    <GetFileExtension><Column/></GetFileExtension>
    </Expr>
    <Case Value="giF">
    <HTML><![CDATA[<IMG SRC="]]></HTML><Column HTMLEncode="TRUE"/><HTML>"</HTML>
    </Case>
    <Default>
    <Column HTMLEncode="TRUE" AutoHyperLink="TRUE"
    AutoNewLine="TRUE"/>
    </Default>
    </Switch>

    Create a new Column of type Calculated - put some logic in it like so

    =IF(AND(Impact="3",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="3",Probability="2"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="3",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="2",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="2",Probability="2"),"/_layouts/images/KPIDefault-1.giF",
    IF(AND(Impact="2",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
    IF(AND(Impact="1",Probability="1"),"/_layouts/images/KPIDefault-0.giF",
    IF(AND(Impact="1",Probability="2"),"/_layouts/images/KPIDefault-0.giF",
    IF(AND(Impact="1",Probability="3"),"/_layouts/images/KPIDefault-1.giF","other")))))))))

    NOTE: The Impact and Probability are columns in the SharePoint List.  Based on this logic, I am re-using the images from the KPIs in MOSS and simply pointing to them.

    And that's it!   You now can output images for your List.  Here is how it looks

    image

Currently rated 3.8 by 4 people

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

Tags:

WSS 3.0 | MOSS 2007 | CAML | Calculated Fields

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