Archive for June, 2008

Easy opening of SharePoint Designer

A tip that much has been made of, but good nonetheless - in Internet Explorer, set the Default program for editting pages to SharePoint Designer to make life easy. Go to Tools > Internet Options > Programs > HTML Editor and select SharePoint Designer.

Configuring IE options

Then in Internet Explorer you’ll have the option to open SharePoint Designer to edit the page. And that’s what it does.

Opening the page in SharePoint Designer.

Why I was getting duplicate rows from the SharePoint Lists Web service

A couple of months ago I was making some calls to the SharePoint Lists Web Service, and I found that I was getting the same item back multiple times. This puzzled me - I mean, it was clearly by design, but why would anyone want a copy of the item for each value selected in a multiple-selection lookup?

It hit me last weekend (like a bolt from the blue) - you could use this to support Group By clauses on queries on a list. Yes, I know, SharePoint itself doesn’t support this functionality, but you could use the behaviour that I’d seen to support this. It’s the only explanation I’ve found that makes sense.

Now, can you turn off this behaviour, so you only get one item. That would be a lot more useful for what I was trying to do, although I now get why you might want that behaviour. Well, I don’t see a query option for it in the documentation, and cracking the service open in Lutz Reflector doesn’t show an option for it either.

I guess we’ll just have to accept the GetListItems command in the Web service API supporting Group By functionality, while SharePoint’s user interface itself does not. It’s a bit weird though that there isn’t an option I can find to turn it off though, and the Object Model behaves quite differently - it only returns one ListItem, and is unaffected by the multi-select lookup.

When will a page run inline code in SharePoint?

Previously, I’ve detailed my attempts to show a query string parameter in a page. This should be a simple enough to do as inline code, but as my previous attempts recorded, when I tried:

<%= Request.QueryString.ToString() %>

I got the error “code blocks are not allowed in this file”. This makes sense, as otherwise anyone with SharePoint Designer could put arbitrary code into a page and get it to run. Clearly, as this would let business users enter code, this would not be very secure.

Now, you can turn off this security restriction using Page Parser Paths, but this reduces the security of the system - again, anyone with SharePoint Designer could put code in without review/authorisation. Again, less than ideal.

Well, one of the things I learnt last week was that uncustomised pages (or ‘ghosted pages‘ for the oldies) will run inline code. Fantastic! After all, we’re going to want to package up our code for deployment from Development to Testing and Production systems, right? (Well, you should be, dammit!)

For those of you who don’t know, uncustomised pages are ones that are stored on the server’s hard drive, rather than in the database. To get onto the hard drive, someone has to install them, which means that someone has to review and approve the code. With SharePoint designer, this isn’t the case, and SharePoint Designer can only create pages that are Customized (or Ghosted), and so exist only in the database.

So overall, the process would probably become:

  1. On a development system use PageParserPaths to enable inline code. As this is a dev system, security is less of an issue, and business users won’t be making changes.
  2. Develop your pages that use inline code. You can do this in SharePoint Designer.
  3. When the pages are complete, copy them out and package into a feature. Make sure that your page that you’ve written in installed Ghosted - still the terminology they use in features.
  4. Install and activate the feature. As your page is now uncustomised (or ‘ghosted’), it will now run inline code without PageParserPaths being configured.

That’s a pretty tidy developer story!

Training with Ted Pattison Group

Last week I was away training in London - hence the last of posts on the tail of last week. I was at ‘Xpertise’ in London, although the training was being provided by Ruth Jennaway on behalf of Ted Pattison Group. The course itself was SPT 401 - Inside SharePoint Products and Technologies, though I can’t find this on their website. Read more »

How do I get rid of the Action Links on my Search Results Page?

I wanted to get rid of the Action Links on a standard Search Results page in SharePoint:

Standard Search Results Action Links

So I opened up my search page in SharePoint Designer. This always looks a bit cluttered, but I went to my Core Search Results Web Part to modify it’s ShowActionLinks property.

SharePoint Designer view of Results page, showing that ShowActionLinks is already False

I’ve scribbled on this to highlight the obvious web parts on the page. The Core Results web part is highlighted in cyan. Anyway, if you look at the code in the top of the screenshot you can see that the ShowActionLinks setting is already False. Eh? Read more »

Saving SharePoint Searches

One of my colleagues was asking how to save a SharePoint Search. It’s a bit of a question of how many ways to skin a cat…

The important thing to remember is that a simple search is just a URL, and specifies the search term and scope in the k and s parameters respectively. E.g. This search url:

http://deltamoss01/searchcenter/Pages/Results.aspx?k=Badgers&s=All%20Sites

would run a search for badgers in the All Sites scope.

It is worth noting, however, that this is saving the search, not a set of search results. As the index is updated, the results on this page may vary. Also, advanced searches don’t pass their parameters as GET parameters (i.e. within the URL), so you can’t save these the same way. I’ve not yet found a way to save them.

As another note, the standard Search results page shows the ‘Alert Me’ link:

The Alert Me Link

This lets you set up email alerts about new items that match a search:

Alert Me Configuration Page

Really, that’s pretty neat. Read more »

Advanced Search - Losing Parameters

I have a bit of a problem with Advanced Search in SharePoint - it’s very awkward to use.

When I perform a standard search in SharePoint, it shows me what I’ve been searching for:

Search Results showing Search Term of Snake

That’s good - it’s useful to know what you’ve searched for. If I then click on ‘Advanced’ the advanced search page opens showing my search term, and a number of other fields I can fill in for a more specific search.

Advanced Search Screen with Search term of Snake

If I then run that search, though, I get the following results page:

Search results, but with no apparent search term

Okay, now that is a little odd looking. There is no search term in the search input box. This is perhaps not surprising - the advanced search screen can express more complex queries than the text input box of the simple search control. However, there is nothing to tell you what the results are of. You have no idea what the search was that gave these results!

Worse happens if you try to go back to your advanced search page. Unless you use the browser’s Back button, you will lose your current query. There is no obvious way of ‘refining’ an advanced query.

It looks like this is happening because the simple Search box passes it’s parameters in the URL as GET parameters, but the Advance Search page uses a postback-then-forward approach.

Is it too much to ask for to have a web part that describes what the conditions of an advanced search are, and to store that query to pass back to the Advanced Search page, should the user wish to refine their query.

« Previous Page