December 2008 - Posts

That's not valid XML!
31 December 08 10:44 AM | Blogging about SharePoint: Posts
Body:

The rich text edit control for a multi-line text box field generates DIV tags that include syntax like this:

<div class=ExternalClassAC0995C70E0C4890A5FDA9127A22F537>

NOTE that there are no Quotes (") around the value side of the class declaration.

When I try to use an XMLDocument object to work with the content I get back from the SharePoint field, it throws an exception because it says that the DIV tag is not valid due to the lack of quotes in the class attribute value.

This looks like a bug, yes?

Michael

Published: 12/31/2008 7:44 AM
Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks
Which views can be used when Creating an Alert ?
28 December 08 01:35 AM | Blogging about SharePoint: Posts
Body:

When you create an alert on a list, you have the option of specifying a view which limits which items would trigger the alert.

image

Note however that the list of views you can choose from is a subset of the views available on the list.  In fact, if you don't have any views that are ok to use for alerts, you won't even see the option to select a view.

What are the rules that determine which views are available for use?

Experimentally, my guesses are:

1) It must have a where clause.  All Items views don't show up in the list of views, and it's pointless to use an All Items view because it doesn't filter.

2) It must be a public view, it cannot be a personal view.

3) It cannot involve content approval.

To try to substantiate these guesses, I went to the source with .NET Reflector (http://www.red-gate.com/products/reflector/).

The page to create a new alert is _layouts/subnew.aspx.

Its code-behind is the SubNewPage in the Microsoft.SharePoint.ApplicationPages dll.  This is in Inetpub\wwwrooot\wss\virtualDirectories\<dir for the web app>\app_bin.

You need to open it in Reflector.  Some of the other SharePoint DLL's are in the GAC, so you may need to copy those DLL's out of the GAC into a more accessible place.  To get a dll out of the GAC, use the command prompt to look around c:\windows\assembly rather than windows explorer.  My copy of the Microsoft.SharePoint.dll and Microsoft.SharePoint.Library.dll was c:\windows\assembly\GAC_MSIL\<dll name without extension>/<version number>_<public key token>/

image

Once you have the ApplicationPages DLL open in Reflector, find the SubNewPage class.  Note It inherits from SubNewEditBasePage, so we now look at that base class because SubNewPage doesn't do anything specific to the list of views. 

Within SubNewEditBasePage, there is an InitForm method that walks through the views for the current list, and only adds to the drop down list the views it likes.

image

The code here is a little hard to understand due to the goto's, but some of the details we can pick out are a qualified view is added to the drop down list box in section 58B and that that in order for the view to be listed:

  1. The view cannot have its Hidden property true.  Checked within the 56A section.
  2. The view must have a title - probably the nameless views used by certain list viewing web parts do not (a guess).  Title is checked within the 57B section.
  3. The view must have a where clause.  This is checked in the 5F7 section.  Let's look at GetFilter more closely.

image

Here we can see that if v.Query is not null (which I interpret as "if there is a where clause") and the query does not use the DateRangesOverlap tag, then we can consider the view further, for possible inclusion in the drop down list.

The next thing it does of significance is to call ValidateFilter on the where clause XML. 

image

This is a thin wrapper around ParentWeb.Request.ValidateSubscriptionFilter.

image

Uh oh, it looks like we are getting into unmanaged (non-.NET) code.  Sure enough, this is where we hit the wall:

image

We can't look inside this with .NET Reflector, so this is the end of the line.  If anyone else has information on what the rules are for which views can be used in alerts, please leave a comment.

--Michael

Category: SharePoint – WSS and MOSS
Published: 12/27/2008 10:35 PM
Attachments: http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_10.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_12.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_14.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_2.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_4.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_6.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_8.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_1.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_2.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_3.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_4.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_5.png
http://blumenthalit.net/blog/Lists/Posts/Attachments/95/image_thumb_6.png
Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks
Search Solution Success
27 December 08 10:43 AM | Blogging about SharePoint: Posts
Body:

I've built a small search solution which I think is pretty neat. 

The problem:  Customer has a team site with many, many children team sites.  Each child team site is for a project team, and the company does about 300 projects per year.  Currently, navigation to a specific project team site from the parent team site is via a drop down menu on the global navigation.  This is an awful user experience because the menu has so many items that it is practically unusable. 

Other requirements: Project sites have seven distinct attributes: project name, project id, project manager, department, project program, status, and URL.    Search can be done on any attribute other than URL, and each search result should display all attributes.

Solution: Replace the menu item that has the drop down list of child sites with a menu item that links to a custom search page. This page lets the user easily search for a project site by any of the six attributes. 

In this site collection, the only sites are the parent site and all the children sites - in other words, only the parent site and all the project sites.  Create a Site Directory site, and customize the Sites list so that it can store all seven attributes of a project site. Set up a managed property for each of the seven columns.  Do this in the SSP responsible for the indexer that crawls the site.  Create a search scope that consists of a path rule (the URL to the Sites list) so that only the Sites list is in the scope. 

Create a web part page in the Site Directory site, in a document library -one that has a variety of web part zones, including at least one zone arranged vertically.  On this web part page goes one custom web part which provides the query user interface (more about this in a bit).  Beneath that goes the search results paging web part, then the core results web part, then another search results paging web part.   Configure the search core results web part - open its task pane.  You want to make all the managed properties for the Sites list available for use.   You do that by listing them in the Selected Columns textbox.  This list is specified as XML, and you just add some nodes following the existing pattern.

image

Use the XSL Editor. Configure the XSL that formats the results so that individual search results display the appropriate metadata. In the XSL, use the right CSS classes so the search results use the company colors (if needed.  If you have access to the style sheet used by the site collection, you can change the styling there.  In this case, that file was owned by someone else, and in order to limit my changes to only the areas I wanted to affect, I did the style changes locally.).

image

The custom web part was an ASP.NET web part that included a user control which displayed two text boxes, 3 drop down boxes, and 1 people picker control plus a search button and a clear button. It was of course wrapped in a feature wrapped in a solution.  On the user control, the 6 search criteria controls were laid out in 3 rows of two, with the project name and project id controls being the text boxes, the  project status, program, and department being drop down list boxes, and project manager being the people picker control.  The choices for the drop down list boxes were populated from the filed definitions for the corresponding fields in the Sites list. 

When a user clicked the search button, the web part would build a keyword query in URL format, and refresh the web page with the keyword query in the URL.  For example, if the user did a project title search for "foo" and the search page is named projectsearch.aspx, then the URL that would be navigated to would be, before URL Encoding:

projectsearch.aspx?k=projecttitle:"foo"

All my query web part had to do was build the URL.  The standard Core Search Results web part, seeing the URL parameters would do the actual search and display the results.

You can specify the scope you created either in the core search result web part  properties or in the URL.

Pretty neat, huh?  I think I've done a good job of providing a functional solution while maximizing use of the out of the box capabilities and configuration and minimizing the amount of work that needs to be done in Visual Studio.  It also shows how this customer is now getting even more value out of the built in enterprise search functionality.

Next my customer wants a version 2, which supports wildcard searches and allows each user to save their own search defaults.

 

That's all for now.

Happy Holidays!

Michael

Published: 12/27/2008 7:43 AM
Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks
Best Practices for SPList access and Web Part development
02 December 08 01:50 PM | Blogging about SharePoint: Posts
Body:

So I've been looking through the new (as of 5 Nov 2008) SharePoint Guidance on Microsoft.com at www.microsoft.com/spg .

It's not immediately obvious, but if you click on the last (right-most, at least in left-to-right languages) breadcrumb, you get a drop down list of other very useful sections that are also SharePoint P&P Guidance.

image

Under Development Activities for example,there are 7 How To's - go here to see them all: http://msdn.microsoft.com/en-us/library/dd206918.aspx

The one that is currently of interest to me is  How to: Wrap a User Control Inside of a Web Part for SharePoint.  This is because I need to build a web part or two right now, and a user control provides a nice design surface, that the web part itself does not.  This article provided step by step instructions, but no code download.  Since I had to create a web part anyway, I followed the instructions and posted the resulting project to my 3rd CodePlex project, http://www.codeplex.com/PNPUCinWP .

You can download it from there - it should save you some time.

Also, one of the two QuickStarts shows 3 different ways to access a SharePoint list.  The three ways are:

  1. Direct list access
  2. List Item Repository (1 layer of abstraction)
  3. Entity (such as Announcements) Repository (2 layers of abstraction)

These are explained at the end of the QuickStart, which is here: http://msdn.microsoft.com/en-us/library/dd206917.aspx 

--Michael

Published: 12/2/2008 10:51 AM
Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks