Resetting a SharePoint List Filter WebPart

I have been using the SharePoint List Filter Webpart a lot this week and one thing annoyed the living hell out of me… there is no option to reset the filter. So, once the filter is set… you need to reload the page to undo it. Not nice, right.

Did some searching on the internet and the only thing I found was people telling to add a “reset” link on the page which refers to the page itself so the user actually reloads it.

Then I noticed the “Advanced Filter Options” in the WebPart properties pane. I never gave this much attention.
And yes, one of the options in that collapsed pane is ‘Show “(Empty)” value’. This will add “(Empty)” to the top of your list and acts as a reset.


Expose the Web Part Title in the XSL of your CQWP

The last couple of days, I have been busy with customizing the OOTB Content by Query Web Part and Summary Links Web Part from SharePoint 2010. I wanted to get rid of the default look and chrome and present my data in a nice box with rounded corners and a title with matches the rest of my styles.
After 2 days of trying, I can say… the result is too my liking. 🙂

The first box is a Summary Links Web Part and the box below it, is a Content by Query Web Part.
To get rid of the default chrome, I simply set it to None in the Web Part properties.

Read more

Create a cache profile in SharePoint using PowerShell

I have been looking for a way to create a new cache profile in SharePoint using Powershell. This profile can be used in the Page Output cache.
I noticed that cache profiles are stored in a list called “Cache Profiles” and implement the “Page Output Cache” content type.

So, creating a new profile shouldn’t be that difficult.


To add the profile to your Page Output Cache and enable the cache, you can use the following code:

Create Content Organizer Rules using PowerShell

I just wanted to share a way to create Content Organizer rules in SharePoint 2010 using PowerShell. I was looking for a way to implement those rules using a script.

The first thing I did was create a rule using the UI and then fire up SharePoint Manager to have a look at it and how it has been built up.

So, those rules are stored in a hidden list called “Content Organizer Rules”. Creating a new listitem in that list however is not that straightforward. I did found out that a rule is actually an instance of the Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule class. The link above contains an example on how to create a rule programmatically.

If it’s possible in C#, then it must be possible in PowerShell.
The script below is what I came up with and it works like a charm:

The thing to remember is the ConditionsString property. If you don’t specify a specific condition, you can’t just leave it empty. You have to include the tags of the Conditions element. If you do need to specify additional conditions, then the easiest way to construct this string is to create the rule in the UI, inspect the Xml string of the rule with SharePoint Manager and look at the “ows_RoutingConditions” argument, which contains the condition.

Limit available web templates in your custom site definition

SharePoint 2010 allows you to create custom web templates or site definitions.
Using the UI, you can limit the available web templates which users are allowed to use if they want to create a new site.

The problem with this is that this is a manual action, to be done after creating a new site. It would be a lot better if the available web templates are always limited without having to do this every time you create a new site.
This is possible and can be done by using a custom site definition or web template where you can specify which templates are allowed. You can specify this in your custom onet.xml.
In this file, you have a Publishing feature with ID {22A9EF51-737B-4FF2-9346-694633FE4416} where you can add a property with the key “AvailableWebTemplates”.AvailableWebTemplatesThe value for this property is a list of web templates.
The format of this list has the following syntax:


The FeatureID is the GUID of the feature which contains the definitions for the web templates.
The WebTemplateName can be found in the elements.xml of the web template.


AvailablePageLayouts property value has to be one a single line

Today, I was deploying a custom web template in SharePoint 2010 in which I had specified that only 9 custom page layouts were allowed. I did this by adding a property to the Publishing feature (id 22A9EF51-737B-4ff2-9346-694633FE4416) in my custom onet.xml file called AvailablePageLayouts where you specify the location and the name of the allowed page layouts.
The format of the string with the list of layouts you specify as the value for that property has to be specific:

  • the location of the page layout has to be a relative URL
  • they have to separated by a colon (:)

After I deployed the feature I created a new site from my custom template and all of a sudden I got an error:

All Page layout urls inside the string have to be server relative

The error message furthermore mentioned more information on which page layouts were affected.

When I looked at the list of page layouts I added to this property, they all had relative urls.
Since the 1st layout was not mentioned in the error, something started to go wrong with the second one. I placed each page layout on a new line because that was so much easier than a single line and this was the problem. So, I put everything on a single line and for sure… this solved the error. My site was created successfully and only the 9 specified page layouts were available.

Update (4/12/2011): Someone commented on this post that you can actually split the page layouts over multiple lines for readability. You just need to start each new line with the colon. And he’s right. The next does work:


“s4-notdlg” not doing what it should be doing

Today, I was playing around in SharePoint 2010 and I was setting up a FAQ where you show the questions using a CQWP and open the details in a SharePoint popup dialog. Works great but the problem was that I was trying out a custom masterpage and the dialog showed the complete masterpage with the header, left navigation and so on… not what you want. I switched to a OOTB masterpage and it worked. So it had to be something in my custom masterpage.

Then it hit me, you need to add the s4-notdlg class to the elements you don’t want to render in a popup. Offcourse! Stupid!

I added the class but damn… still no joy. I found a post from Ben Ramey where he explained the same behavior if you forgot the <SharePoint:CssLink runat=”server” Version=”4″ />. But this tag was included in my masterpage. So, this was not the reason.

I started comparing an OOTB masterpage with mine and starting changing small things here and there, testing along the way.
And I found the culprit… it was the runat=”server” attribute on the <html> tag which wasn’t in mine. After I added it, the tags which had the s4-notdlg class didn’t render in a dialog anymore.

Another thing I noticed was that some items didn’t show up directly in the CQWP. Even if I checked them in. Did some searching and I stumbled on an article of Michael Nemtsev where he explains this and gives a workaround. (Why Content Query Web Part (CQWP) doesn’t return all results)

SharePoint Builds summarized

I’m often troubled with SharePoint deployments where you need to find out which version they have installed.

That’s easy, right? You just open up Central Administration, look at the Servers in the farm and woila, you have the build. Finding out which CU that is, is (again) very easy using Google. But sometimes you get an overload of information. I noticed that there is a lot of information out there which is simple wrong! Wrong build numbers, wrong articles, outdated links… So, I decided to get it over with and put em all in an Excel sheet. Done with googling around, wresting through KB’s and so on.

Just a plain and simple Excel sheet with the version, the KB number and a link to the KB article and this for MOSS 2007, WSS 3.0, SharePoint 2010 (SPS and SPF). This way, I always have that information at hand when I’m working at a customer. I just have to keep in mind that I need to update it when a new hotfix is released. 😎

You can download the Excel sheet here: SharePoint Versions

If you notice that some information is wrong, please let me know. I tried to get it right, but I’m not perfect. 😉