Making Sense of the SharePoint World

Nov-242008

Twitter SharePoint Federated Location Definitions - Ready to Serve

MMj02237800000[1]"Is it Soup Yet?"

My last two blog posts on SharePoint and Search Server Federated Locations (Part 1 and Part 2) have been very popular, but some of you have just wanted to download the location definitions without having to read through all of the gory details of their preparation. So, for those who crave instant gratification, here they are!

Download the "basic" Twitter search results Federated Location Definition Download the "deluxe" Twitter search results Federated Location Definition
image image

 

Who says there's no such thing as a free lunch? :)


Nov-222008

Search Federation Part 2 - Customizing Results with SharePoint Designer

MCj04348810000[1]Welcome back! This post will be the conclusion of my Search Federation article. In Part 1, I talked about Federation in Microsoft Office SharePoint Server (MOSS) and Microsoft Search Server (MSS/X), and showed you how to create a basic Federated Location to query an external resource - in this case, Twitter.

While that Location definition is functional, it doesn't really bring the "feeling" of Twitter into your SharePoint search. Sometimes, that may be exactly what you need. However, today, I'm going show you how to take it to the next level by using SharePoint Designer.

This post assumes you have already read Part 1, and have access to the Federated Location created there. You can either follow the instructions in Part 1 now, or download and install the Location from here.

A Starting Point

I'm going to use the basic Twitter Federated Location I created in Part 1 as the starting point for our prettier, deluxe version. To start, Go into Central Administration, and navigate to the Manage Federated Locations page. Find the Basic Twitter Results location, and select Copy Location from the drop-down menu.

image

All of the settings we created for that location will now be pre-fed into a new location definition, except for the Location Name. We're going to call this location "TwitterDeluxe", and change the display name to Enhanced Twitter Results. Otherwise, leave everything the same for now, and click "OK".

image 

Once you have saved the Location, it will appear in the list along with all of the others.

Exploring the Source

In order to see just what we can do with our Location, we need to know what is "in" it. The key component is the Query Template, where we told Search Federation what to query. Let's review the Query Template for our Federated Location.

Go back into the properties by selecting "Edit Location" from the item's menu. Once the editing page opens scroll down to the Location Information section, and expand it. You will see the query defined by Twitter:

http://search.twitter.com/search.atom?q={searchTerms}

To generate some example data, I'm going to replace the {searchTems} token with an actual value - "SharePoint"

http://search.twitter.com/search.atom?q=sharepoint

Clicking this link will call the Twitter search service, and return an Atom feed of the results:

image

Notice that there is much more information showing than we saw in our Federated Location result set, including such information as the Tweet's author, and the date/time stamp. So, how do you get to this in the Federated Location?

In Part 1, even though we didn't change it from its default values, I told you that the Display Information section of the Location definition was going to play an important role in this Part. Now's the time. In the Edit Location page, scroll down to the Display Information section and expand it. I'm only concerned about the first block: Federated Search Results Display Metadata.

image

Notice there are three properties here:

  • XSL
  • Properties
  • Sample Data

All of these properties are nice XML and XSL files. Personally, I'm not a big fan of manually editing XML and XSL. Fortunately, we have a wonderful tool designed just for editing such data - SharePoint Designer. in a perfect world, we could just add a Federated Results component to a page, assign the appropriate Federated Location, open the page in SharePoint Designer, and edit it to our heart's desire.

Unfortunately, we don't live in a perfect world. Yes, we can open the page in SharePoint Designer, and edit the part. But no, we don't have access to "The Full Monte". It starts out promising. We can uncheck "Use Default Formatting", view the source from our RSS results, and paste that into the Sample Data field. When we save the Location, assign it to a Federated Results Web Part, and open the results page in SharePoint Designer,  we can see the sample data:

image

We can even change the format of the existing columns. But, although SharePoint Designer recognizes the Federated Results as a form of Data View, it doesn't give us full access to the Data View editing features. We can't easily get to the rest of the information we know is coming from the feed. Since Federated Search arrived much later than SharePoint Designer, I can't really fault SPD for not fully supporting the web part, but I hope that gets resolved in a future update.

You might think that this leaves us at an impasse. But it doesn't. Because, while SPD doesn't give us full Data View support on the Federated Results web part, we do have another way to edit XSL - the original Data View/Data Form Web Part!

A Data View Refresher

The Data View Web Part is a way to display information from virtually any source within SharePoint. Data Views are created in SharePoint Designer, in association with another feature called the Data Source Library. This is not to be confused with the "Business Data Catalog", or BDC. While both the Data Source Library and the BDC deal with presenting data from external sources within SharePoint, the BDC is a part of MOSS Enterprise, and allows a much deeper integration of the data with various aspects of SharePoint. The Data Source Library, on the other hand, is available in all editions of SharePoint - from WSS on up - and is primarily used to generate Data View/Data Form Web Parts.

Data Views and the Data Source Library are a very powerful combination - so much so that almost two whole chapters of my book are devoted to them. Obviously, I can't go into that kind of detail here, but while this particular example is fairly simple, it covers a lot of ground.

The link between Federation and Data Views is pretty close. In fact, prior to Search Server or the Infrastructure Updates, you could use a Data View to achieve very similar results. We're going to take advantage of this by building the look we want in a Data View, then transferring it into the Federated Location definition.

Creating a Data View

Before we can create a Data View, we need create a new item in the Data Source Library for our Atom feed.

To do this, Select "Manage Data Sources..." from the Data View menu in SharePoint Designer to summon the Data Source Library task pane. Atom and RSS feeds fall into the category of "Server-side Scripts" that return XML, so expand the Server-side Scripts section and click "Connect to a script or RSS Feed." You will see the dialog below. Fill in the URL with the same Twitter Atom query we have been using:

image

The query parameter (q) will automatically be passed into the list as soon as you change the focus from the URL field. "SharePoint" will become the default parameter value, and give us something to see as we customize the look.

Now that we have the Data Source, we need a place to put it. This can be any web part page. While you can use the results page if you feel so inclined, because we aren't going to be using the Data View directly, it doesn't need to be.

Once you have a web part page open, select a Web Part Zone, and then pick "Insert Data View..." from the Data View menu. The Data Source you created above will have a drop-down menu associated with it. Select "Show Data".

image

You will see the Data Source Details task pane, with the structure of the Twitter Atom feed displayed.

image

I've maximized my task pane for this screen shot in order to show you how the SharePoint Designer data source displays the entire structure of the feed. Notice the folders and item scrolls for the various elements. The Twitter Atom feed is a "hierarchical" data source. This means that the data has nested, potentially (and in this case, actually) repeating, elements, which in turn may have their own nested elements.

For now, the primary entity we are interested in is the "Entry" folder. Look at the screen shot to the right. Highlight the elements in the "Entry" folder as shown, and select "Multiple Item View" from the "Insert Selected Fields as..." menu. (Yes, I know. It looks like a button, but trust me - it's a menu!)

A table will be inserted into the web part. That's got most of the information we want, but it isn't terribly pretty. So, let's fix it up!

The first column contains the "href" entity. Ironically, even though there is a separate entity for the Author, one of the two links listed for each user is the Author's avatar. The other is a link to the Twitter URL of the tweet itself. For our results, we really only want the avatar, so we're going to do two things - Change the display to show the image instead of the URL, and hide the other URL.

To change to an image view, click one of the URLs in the href column. To the right will be a little box with a chevron in it:

image 

When you click it, you will have choices to modify the current field. Select Picture.

image

You will get a warning that URLs and Pictures can be dangerous. We know that, so click Yes.

The changes you make here will affect all of the items of that series. (You probably noticed that they were all highlighted in a different color when you clicked on any one of them.)

Once you have done that, to suppress the other image (which will show as a "broken" picture), Right-click the broken link and select "Conditional Formatting". In the Conditional Formatting task pane, select "Show Content" from the "Create" menu (another one of those "buttony" menus). In the Condition Criteria box, set the conditions like this:

image

The broken link will go away.

Next, we want to merge the rest of the cells in the row. This is just like any other table action - highlight the data cells (not the labels) for content, updated, name, and uri. Right-click, and select "Modify/Merge Cells". Now we're cooking! Just a couple more tweaks, and it will be there.

Select the tweet content text, and change its format to Rich Text (just like changing the image format above).

Select the date, and format it to your regional liking.

Notice that we have a link to the Author, the Author's name, and the Author's avatar. Wouldn't it be great to have the name and the avatar actually link to the Author's page? Well, we can. If you click the chevron by the link, you will see that the field being displayed is called "ddw1:author/ddw1:uri". For the text, change the format to Hyperlink, you will see the following dialog. You can use the "fx" icons to select the fields you wish to use in the hyperlink, or enter the values manually. In either case, you want the "Text to display" and "Address" fields to be set as shown:

image

Setting the link on the picture is easy, too. Just right-click the image, and select "Hyperlink" from the context menu. Set the address to the same token as you used above. Now you can delete the field that shows the text of the author link.

You should now have a web part that looks a lot more like what you would expect from a Twitter search:

image

Pretty good, but I'm still not satisfied. :)

Notice the Chevron icon in the upper-right corner of the web part.

If you click it, you will summon the "Common Data View Tasks" menu:

image

Click Data View Properties. You will get this dialog:

image

Click "Show view header" and "Show view footer", then click the "Paging" tab.

Click "Limit the total number of items displayed to:" and enter a reasonable number for a search results page. (I picked 5). (You need to do this because the XSL we are creating will not have a link to the Federated Location web part's "Results per page" property.) Click OK.

Display the Data Source Details task pane, and drag the first title field available into the newly created header. Click in the footer, and delete the Item Count. In the "link" group (above the "title" field you just used), make sure item 1 (rel = "alternate") is selected. Highlight the "href" and select "Item(s)" from the Insert Selected Field menu. Change its format to a Hyperlink. Leave the Address as-is, but change the Text to Display to "More Results..."

I'm going to delete the field name row, rearrange the fields slightly, and also apply the style "ms-searchChannelTitle" to the Header cell. This results in a part that looks like this:

image 

Moving the XSL

Now that we have something that looks how we want it, how do I get this style into my federated location? If you don't like code, this is going to get a bit messy, because now we need to enter "Split" view in SharePoint designer. Essentially, we need to copy the XSL markup from this web part. To do this, click the "Split" view icon at the bottom of the SharePoint Designer design surface workspace window, then click the title bar of your web part. This will highlight the code that makes up the web part. Using the scroll bar, Scroll through the highlighted code area until you you find the <Xsl> tag. It will be followed by lots of code. You want to copy everything below the <Xsl> tag until you find the closing </Xsl> tag to the clipboard. (Do not include <Xsl></Xsl> themselves.)

Now, go back to your "TwitterDeluxe" Federated Location definition in Central Administration. Go to the "Display Information" section, and replace the contents of the "XSL:" field in the Federated Search Results Display Metadata with the code you just copied. Click OK to save the changes.

The Net Result

Now you can go to your results page, and assign your Enhance Twitter Results location definition to your Federated Results web part. Here's what it looks like in action:

image

Now, this was a lot of steps. In reality, it is a lot faster to do than to describe. However, as promised, I am making this location available for you to download.

Click this link to download the Federated Location definition file.

I hope you have enjoyed this article!


Nov-182008

Search Federation with SharePoint - Part 1

MCj03832420000[1]

Today I'm going to walk you through setting up a Federated Location in Search Server and post-Infrastructure Update SharePoint. (Twitter fans, pay attention, as that's the service I'm using in these examples...) While that certainly qualifies as "Back to Basics", that's just "Part 1". I'm not stopping there. The second part of this article will to show you how to take it to the next level by using SharePoint Designer's XSLT Data View editing capability. I'm even making the Location definition files available for you to download and use in your own sites!

What is Federation?

When Microsoft introduced Search Server (MSS) and Search Server Express (MSSX), they introduced the concept of "Federation". With the Infrastructure Update, they brought Federation directly into Microsoft Office SharePoint Server (MOSS). Federation allows users to send the same query to multiple independent repositories, and display the results from each in its own region on a results page. In the example below, the query "SharePoint" is not only generating results from the internal site, but from Live.com search as well.

image

Note that with Federation SharePoint and Search Server aren't crawling the content themselves. They're just acting as the "middle-man". All SharePoint or MSS/X are doing is passing on the query, then receiving, formatting, and displaying the results. The other service is doing all of the heavy lifting.

Setting Up a Federated Location

Microsoft has provided a very easy method for adding Federated Locations to your MOSS and MSS/X installation.

Through Central Administration, Click into your Shared Services Provider (SSP). On Search Server, you will be taken directly to Search Administration. In MOSS, you will need to manually navigate to that page. Once there, you should see "Federated Locations" in the Administration Bar (Quick Launch). You will see the page illustrated below:

image

Note: If you are using MOSS and do not have an Administration Bar in your Search Administration page, you do not have the Infrastructure Updates installed. Search Federation was added to MOSS by these updates (along with a lot of other improvements), and they must be installed before you can proceed. Read all about them on the Microsoft SharePoint Team Blog.

On this page, you can see some nice stats for the Federated Locations on your system. You can also import pre-created Location files, edit existing Locations, or create a new Federated Location. It is that last option that interests us today. When you click "New Location", you are presented with a very long form:

image

While there are a lot of fields, the main reason this form is so long is because of all of the "tutorial" information embedded in the descriptions. It is definitely worth a read. I've started filling it out in the screen shot above. As mentioned in the introduction to this article, I'm going to be creating a location for the Twitter micro-blogging/massively-multiuser-chat service.

Next I enter who I am, and the version of this Location:

image

I'm leaving the "Trigger" at its default of "Always". this is one of the places you can get really fancy with your definition, at least as far as determining when you want to actually invoke a query.

Next, we need to enter some information about what the target of your queries expects. In this case, we're going to tell the Federated Location to use the OpenSearch protocol, which sends your query terms as a URL parameter.

image

The Query Template lets you define the parameters your target, in this case Twitter Search, requires in order to return a result. I got this from Twitter's online API documentation. Since SharePoint and Search Server support Atom responses, that's the format I chose for Twitter to emit for its results.

The last thing I'll enter for this Federated Location is a link for "More Results". Again, the Twitter API documentation shows us that for "normal" results, we just omit the ".atom" from the URL. This parameter is optional, but very useful:

image

Note: While we aren't changing anything in the "Display Information" section at this time, this setting group will be very important to us in Part 2.

That's all there is to it! Click OK to save your new Federated Location, and it will appear in the list on the Manage Federated Locations page:

image

Using your Federated Location

Now that you have created your Federated Location, you need to add it to a Search Results page. The easiest way to do that, is to go to your Search Center, enter a query, and once you have the results, select "Edit Page" from the Site Actions menu. Click "Add a Web Part" in the banner of a Web Part zone. In the dialog that appears, select the Federated Results web part and click Add.

This will add a new Federated Results part to your page, but it probably won't be displaying the Twitter results. You now need to edit the part to point at the Federated Location you want.

  1. From the Edit menu of the web part, select Modify Shared Web Part
  2. In the Location Properties section, select "Basic Twitter Results"
  3. Click the "Apply" button.

You should now see results similar to the following:

image

Exit Edit mode on your page, and you're done!

image

You can download this version of the Twitter Federated Location file here.

Click Here to see Part 2!


Nov-152008

It's in There - Automatically Maintained Columns in SharePoint Lists

MMj02347000000[1]Over the last few weeks, I have veered a bit "off topic". But now that TechEd is over, it is about time to bring things back on track. So today, I'm getting back down to the business of helping you to understand SharePoint with another "Back to Basics" article on the subject of Lists and Libraries.

In this article, I introduce you to some columns that SharePoint creates and manages automatically, and describe some of the ways these can be useful. In the process, you will see how to create a custom list or library view.

Introducing the System Columns

Every list and library type you can create in SharePoint has certain unique characteristics, including fields/columns specific to that list type, a default set of views, etc... (See A List, A View, a Part, in SharePoint) But in addition to the things that make a particular list or library unique, SharePoint also creates a set of System Columns that are common to all lists and libraries. Generally speaking, these columns are "Read Only" from the user's perspective (i.e. users can't directly update them on their own), but they contain very useful information, such as who created the item, and when. They are maintained by SharePoint itself.

The automatically generated, or System, columns in a SharePoint list or library include:

Content Type

Contains the content type of the item. If you have enabled multiple content types for the list or library, users can update this column.

Created

This is the date and time the item was first created. This never changes.

Created By

This is the user who initially created the item. This never changes.

ID

Each item in a SharePoint list or library is assigned a sequential, numeric ID (starting with "1"). This never changes.

Modified

This is automatically updated any time an item is updated.

Modified By

This is the user who made the most recent change to the item.

Type

This is mostly used in libraries. The extension of the file uploaded to the library is stored and used to select an icon to display in your view.

Version

Display's the item's version. If you have versioning enabled on your list, it reflects the version currently being displayed. If you do not have versioning enabled, it displays either 1.0, or the last version number that was created while versioning was enabled on the list.

If the list or library is set to require Approval, two more columns are added to the list automatically. I'm listing them here for completeness, but because they can effectively be edited by site users (with appropriate rights) I won't be discussing them in the rest of this article.

Approval Status

Whether the current item is Approved, Rejected, or Pending. People with permission to approve can change this column.

Approver Comments

When an approver updates the status of the item, they can enter information into this column.

While your users can't update most of these columns, they can be read and used when creating views. Consider the view below...

image

This view includes the Title of the item, and all of the automatic columns described in the first table. From this, you can tell a lot about this list. For example, Content types are enabled (the two items have different types). You can also tell that versioning was - at least temporarily - enabled, but was also disabled for some time, because the first item shows a 2.0, while the second item, even though it was clearly modified (notice the different Created and Modified information), is still showing 1.0 for the version.

Note: Normally, you won't be arbitrarily mixing content types in a list, or enabling and disabling versioning. I have done so on this list simply to illustrate possible different values for these columns, and their behavior.

Using the System Columns

This information, even though you don't enter it yourself, can be very useful. For example, you don't have to worry about someone manually changing records of when a file was last updated. While SharePoint maintains this info, it is available for you to use in customizing your users' experience.

Suppose you want give your users a view of only "their" items? That's as easy as creating any other view in SharePoint!

From the "View" drop-down, select Create View. You are given several options:

image

Notice that, in addition to the stock view formats, you can create a new view using a existing view as its basis.In this case, we're just going to create a Standard View.

I'm going to call the view "My Items", leave it a public view, and include the same custom columns I used in the view above. Notice that you can select the automatically system-maintained columns just like any other column for your list or library:

image

Scrolling on down the page, I'm going to set filters on the Created By and Modified By columns, looking for the token [Me] in either location. This token resolves to the User ID of the person currently viewing the page, so if the current user either created or updated the item, it will be listed for them. Otherwise, they won't see it. (For consistency, I've also chosen the "Boxed" style to match the earlier view.)

image

Now, if Amelia signs in and selects the "My Items" view, she only see the item she edited:

image 

Summary

For any list or library you create, SharePoint creates a set of system columns that it manages automatically. Although your users generally can't edit these columns, you can use them just like any other in the creation of views. I demonstrated one option, filtering based on the current user. But you can also use these columns for sorting and grouping your views as well.

I also showed you how to create a filtered list view, and a select a specific layout. That process applies equally well to columns specific to a particular list or library type, and to columns that that you create.