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>

Be the first to rate this post

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

Tags:

List Event Handler ItemUpdated Event – How to set a form field value programmatically

by oscar 8/12/2008 10:29:12 AM

On my current project we had a requirement where based on the user browsing the SP Site, I needed to set the value of a MultiChoice Field to yes/no.

At first, I had difficult time figuring out why my code was not updating the value of my field.  Here is what works!  Specifically, the SystemUpdate(false) is what did it.

//always set the locked value to YES.
  properties.AfterProperties["Locked_x0020_and_x0020_ready_x00"] = "Yes";

  try
  {
      DisableEventFiring();
      properties.ListItem.SystemUpdate(false);
      EnableEventFiring();

  }
  catch (SPException ex) {}

Hope this helps you,
O

Be the first to rate this post

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

Tags:

Another SharePoint Consultant with a Mac Book Pro…

by oscar 7/20/2008 2:44:59 PM

Apparently I am not the only .NET/Microsoft Platform/SharePoint Consultant that uses a Mac Book Pro, Andrew Connell, Spencer Harbar and others have done this as well.  I just like the hardware Apple produces, plus having the ability to have multiple platforms at hand is awesome!  I’ve been using this hardware for about 5 months and have absolutely no complaints. 

A few days ago I thought it would be terrible to loose all my configuration and software settings should the Boot Camp partition becomes unusable.  So, I went on a quest to figure out the fastest and safest way to backup my entire partition and recover it with minimal downtime.
396
On this partition, I have Windows 2008 and all the Microsoft Office SharePoint Server 2007 required development tools.

On Disaster Recovery

I recently became a bit more conscientious about disaster recovery, and so I thought that I should have a plan to recover my Boot Camp Partition should I loose it for some reason (of course, being a developer, there is a greater chance).

Here are the options I looked at.

  1. Use Windows Server Backup to produce the VHD and store it on an external drive
  2. Use Acronis True Image Enterprise with Universal Restore ( tried restoring to VM but no luck) to create an Image
  3. Use Winclone to backup my Boot Camp partition.

In a nutshell, 1 and 2 failed, there are issues with rebooting it appropriately, I may have gotten it to work, but at this point I wanted to ensure I have something in place sooner rather than later and so I used Winclone.

I used Winclone to accomplish my task.  However, I ran into an issue where as soon as Winclone backed up my partition, it became unusable.  I found out there was some order of the tables that got screwed up, so I ran the gptrefresh command as mentioned by the creator of the tool and it worked!  After running that, I was able to boot again with my Boot Camp partition.

The one thing I wish I had was a 64bit computer so that  I can play with Hyper-V on Windows 2008 Server!

Happy developing using the Mac Book Pro!

-Oscar 

Be the first to rate this post

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

Tags:

SharePoint Designer Workflow – Send Email Reminder X days prior to a Date

by oscar 6/24/2008 2:12:15 PM

Business Problem


One of my clients wanted to send email reminders to users one week prior to the project assigned tasks Due Date.

Solution


As you may or may not know, MOSS does not have that built-in functionality, but it is easily accomplished via a workflow created using the SharePoint Designer 2007.

Architecture

Calculated Column
I feel that working with complex date calculations (view my other post for a more date formulas  SharePoint List Calculated Column - Calculate Business Days) are best done on the SharePoint List side.  Therefore, I decided to have a calculated column that would already have the DateTime for when I need to send my Email Alert.

In this scenario it was fairly straight forward and so my formula simply looks like this:
image

This is what the column looks like when viewing the list items.  If you look closely, you will see that the column Days Prior To Due Date shows 3 days, but my email reminder column says the date to send my email is 6/21/2008.  The reason is that the formula on that column excludes weekend days!  image 

Workflow

The first Step on the workflow – Set Reminder Time

  • I use the Add Time To Date Action, but don’t actually add time, I simply capture the value of the column TaskEmailReminderDate and store it on a variable called ReminderDate for use on my Step 2.
  • Store the Task Title on a variable called SubjectTaskTitle, used when sending my email
  • So that I can debug, I simply use the Log To History List Action to view the value of the ReminderDate variable



image

The Second Step on workflow – Send Task Reminder Email

There are no conditions, this step simply uses the Pause Until Date Action and uses the variable on Step 1 called ReminderDate to send out my email.
image


NOTE:
When I was testing my workflow, I was of course logged in as the “Administrator”, and so the workflow always failed to start automatically!  View this KB article for details.  My resolution was to simply create another account in AD and grant that account admin rights to my portal.  This prevented me from updating the Application Pool Identity for my Web Application.

Well I hope this helps you and let me know if it did!

Cheers,
Oscar

Currently rated 3.0 by 2 people

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

Tags:

Calculated Fields | SharePoint Designer | MOSS 2007 | WSS 3.0

SharePoint List Calculated Column - Calculate Business Days

by Oscar 6/23/2008 12:19:00 PM

Ran into a nice little scenario where my client wanted to know how many business days were remaining prior to a Task Due Date. Once I had this date, I built a nice DataViewWebPart (see Figure 3) with the SharePoint Designer! This is what I came up with, hope it helps you!

A) Create a calculated column; call it something like "Days Prior to Due Date" in my case.

b) Paste this value into a Calculated Column, formula
=(DATEDIF(Today,[Due Date],"d"))-INT(DATEDIF(Today,[Due Date],"d")/7)*2-IF((WEEKDAY([Due Date])-WEEKDAY(Today))<0,2,0)+1

C) Make the output type "Single line of text"

NOTE:
At the time of creating this calculated column, you must have another dummy column called "Today", it does not matter what data type it is. Once you create your calculated column, make sure to delete the Today column or your values will not work!

FIGURE 1 – Shows the formula for your calculated column to count only weekdays.

FIGURE 2 – Shows the sample Due Date and the calculated column output (far right)

FIGURE 3 – Shows you a dashboard with some XSL logic in the background to output an image on the left, and the days remaining calculated column value on the far right

Be the first to rate this post

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

Tags:

WSS 3.0 | MOSS 2007 | Calculated Fields | SharePoint Designer | DataViews

What have I been doing?

by Oscar 5/13/2008 1:09:00 PM

Hi, it has been a while since I posted!  Addmitedly, I have been super busy with what else? MOSS projects :)

I just finished configuring MOSS using Windows Live Authentication!  I think this is a good alternative to using your own SQL Server database.  All you have to do, is assign the Live Accounts to a SharePoint Role, and done!

Keith Bunge has done an excellent job in providing a WSP to enable this functionality.  You can find out more here

Windows 2008 Server Development Environment

Oh yes, I finally had time to setup my new dev environment, and it rocks!  love the new features of win2k8.

 Well, short and sweet this time.

Cheers,
Oscar

Be the first to rate this post

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

Tags:

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.7 by 7 people

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

Tags: ,

MOSS 2007 | CAML | CQWP

Vanity URLs for MOSS/WSS 3.0 sub sites or Top Level Sites

by Oscar 2/21/2008 1:28:00 PM

Have you ever gotten a request from your client on having short urls for some SharePoint sites, even if they are deep in the hierarchy of your portal?  Here is one way I have implemented this to allow a site to be accessible via a url such as http://editorial 

NOTE: This is not the same as using a host header Site Collection which you can create using the stsadm utility with a command like the one below.  This workaround is aimed at 'path-based sites'

stsadm.exe -o createsite
-url http://hoster.contoso.com
-ownerlogin contoso\siteowner
-owneremail siteowner@contoso.com
-hhurl http://www.contoso.com

The business requirement

For this particular project, the business users wanted to access SharePoint sub sites like http://portal.invent.com/Marketing/TeamA, or http://portal.invent.com/sites/Legal with a short url such as http://TeamA, or http://Legal.

Information Architecture and URL Planning

Site URL planning is in fact an activity that is part of the overall planning phase on any SharePoint deployment project.  There are many considerations you must take into account when planning URLs.  To learn more about what tasks are included on planning logical design, go here

Some of those include, but not limited to:
•    Portal taxonomy
•    Global Navigation
•    Storage limits for individual sites
•    Restoring Sites or Site content

These considerations affect your decision on exactly what type of site you will create on MOSS/WSS 3.0.  As you may or may not know, there are several types of sites that one can create, each one is created using different methods.

      Types of Sites
      Host-named Site Collections – These are created using the stsadm
       Host-named site collections give you more control over URLs. However, there are tradeoffs.
First, host-named sites are only available through the default zone. Users who are configured to authenticate through alternate zones cannot access host-named sites. Second, the alternate access mappings feature does not work with host-named sites.

Standard Site Collection – These are created using the Central Admnistration > Web Application > Create Site Collection option.

Top Level Site - These are created using the Portal Site Actions > Create Site option.  You can a url like http://portal/sitename

Assumptions
1.    You are familiar with DNS
2.    You are familiar with running and administering IIS Web Sites
3.    You are familiar with administering MOSS 2007 and/or WSS 3.0
4.    These steps assume you already have the portal running on a Web Application that responds to the url http://portal.invent.com for this example

Configuration Steps

1.    Create DNS entry such as editorial.invent.com
2.    Create an IIS Web Site, type http://editorial for the Description (this IIS site is not provisioned by MOSS, it is a simple regular IIS web site)
3.    Type the host header editorial.invert.com (leave the port on 80
4.    Type another entry in the host header area, this time, just with editorial

Your window should now look like this

image

FIGURE 1 – Shows the host header entries you should have on your IIS Site

And as a last note, we can have both Path-based Sites and Host-named Sites on the same Web Application. You can learn more on Planning for Host-named Site Collections here 

NOTE: Alternate Access Mappings is not used here, because again, MOSS does not know about this IIS Web Site at all, it is not provisioned as a Web Application. 

Cheers,
Oscar

Be the first to rate this post

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

Tags: ,

WSS 3.0 | MOSS 2007 | Site Collection Url

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 2.0 by 6 people

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

Tags:

WSS 3.0 | MOSS 2007 | CAML

Another way to retrieve SharePoint List Data - Use built in functionality!

by oscar 12/10/2007 6:24:23 AM

<UPDATE> My fellow MVP Ton Stegeman has a nice post on yet another way to use the owssvr.dll Export user information to Excel using "Export to spreadsheet" in SharePoint 2007.  He was nice enough to actually create a Feature!
</UPDATE>

Sometimes you just don't want to write your own Web Service .  You could use the built in Web Services, but you can't deploy assemblies to the MOSS server.

So what is one to do?

You can use some neat built in functionality!

Basically you can call the owssvr.dll with specific parameters such as

http://moss.litwareinc.com/_vti_bin/owssvr.dll?Cmd=Display&List={A07519C4-9605-48AA-B0B4-0FFA9E4F0CB1}&XMLDATA=TRUE

When I type this on my browser address bar, I will get a result similar to the one below

clip_image001



At this point, you can use XSL to transform the XML such as in a DataViewWebPart in the SharePoint Designer :)

Filtering results 

What if you need data that meets a specific criteria?

You can add the following parameters FilterField1 and FilterValue1

Say I want to retrieve only the Project Deliverables that have the Stage Column value set to "Delivery", you can filter like so
http://moss.litwareinc.com/_vti_bin/owssvr.dll?Cmd=Display&List={A07519C4-9605-48AA-B0B4-0FFA9E4F0CB1}&XMLDATA=TRUE&FilterField1=Project_x0020_Stage&FilterValue1=Delivery

Your results would look like this

clip_image001[5]


There is a lot more you can do, you can even update a View by changing the Cmd=Display to Cmd=UpdateView

Enjoy!

Oscar

Be the first to rate this post

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

Tags:

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Oscar Medina Oscar
I am a SharePoint Solutions Architect based out of San Francisco, California

E-mail me Send mail

Calendar

<<  August 2008  >>
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
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