Friday, November 28, 2008

Changing the AssetPortalBrowser Behaviour

Following are some instructions on how to change the default behaviour of the AssetPickerDialog also known as AssetPortalBrowser.aspx

1) Change the paging size: That's an easy one!
go to the ProgramFiles\....\12\Template\LAYOUTS folder and edit AssetPortalBrowser.aspx. BEWARE. Do not edit with SharePoint Designer. It will change all the paths and nothing works no more.
On that page you will find a control called ObjectList1 of Type SMObjectList. It has a PageSize attribute wich you can change from 15 to anything you like really.

2)Changing the Default Sort behaviour: Tricky!
Sadly enough setting the SortDirection ad SortExpression on the Control will not come into effect as the sort is overridden every time the context changes. And the context changes every time the page is loaded. Thus, no matter what you set here it does not seem to work.
The Workaround includes some C# and visual Studio knowhow.
a) Create a new Class Library
b) Add References to the the Microsoft.SharePoint, Microsoft.SharePoint.Publishing and System.Web dlls
c) Create a new Class that inherits from Microsoft.SharePoint.Publishing.Internal.CodeBehind.AssetPickerDialog
d) override the OnLoad event and set the SortDirection, SortExpression and ExplicitView of the ObjectList1 Control programatically. Do this after calling the base.OnLoad() event to make sure the control is loaded correctly.

public class CustomAssetPicker: Microsoft.SharePoint.Publishing.Internal.CodeBehind.AssetPickerDialog
{ protected override void OnLoad(EventArgs e){
this.ObjectList1.SortDirection = "DESC";
this.ObjectList1.SortExpression = "Modified";
this.ObjectList1.CancelSortOperation = false;
this.ObjectList1.ExplicitViewName = "All Documents";

e) sign the assembly

f)install the assembly into the GAC either using gacutil or drag&drop it into c:\windows\assembly
g)fix up the web.config to allow the new assembly by I)adding it to the SafeControls list and II)the compilation\assemblies list
h)Change the Page directive on AssetPortalBrowser.aspx to inherit from your new class instead of the Codebehind class.

Voailla, you now changed the default sort to always show the last modified files and images first.

Thursday, November 13, 2008

Data Views and the AdventureWorks Database

If you ever tried to get Data Views to work with the AdventureWorks DB you probably have had as much pain and frustration as I have had in the past.
First you'll need to get SSO set up to connect to the DB. That's simple once you know how!
Then you select the table you want and when you try to show the data you keep on getting error messages! The problem here lies in the fact that AdventureWorks uses Schemas everywhere. And you need to fully qualify your tables to be able to access them. SarePoint Designer is not clever enough and forgets to put the schema name infront of the select command.

Here are two possible solutions:
  1. simply write the select statement yourself instead of picking the table from the list. A simple statement like Select * From Production.Product will get you going in no time.
  2. Create a deidacted login for a specific schema and define the defauls schema.

Here are the steps for the latter option:

  1. Create a login on the SQL Server called AWProduction.
  2. Set its default database to AdventureWorks.
  3. In its user mappings give it pubilc access to AdventureWorks and specify the Default Schema to be Production.
  4. go to the schema definition on the AW database and give AWProduciton all the required permissions on the Production Schema.
  5. Set up a new SSO Application that uses the new AWProduction Login
  6. Use that SSO login for your Data Connection

Hope that helps!

Using Dataviews to edit and update SQL data

If you hooked up your dataviews with SQL data and enable editing you most probably have come across following error message:
The data source control failed to execute the update command

The reason for this can be manyfold, either you might have a data type issue where you have non numerical data being pushed into a numerical field or in my case as simple as a database constraint getting in your way.
Dealing with the select, update, insert and delete commands manually can be a bit of a pain. So I really like the ability to pick my table and let SharePoint Designer worry about the rest. Just a shame that SharePoint designer does not understand one simple rule. You can not update a column which is the identity column of a table. SQL server reserves the right to auto increment that column. How to fix it? two ways:

The simple way:
Start with a blank Data View and make sure not to add the ID column to the list.

What if you want to show the id though?
The hard way:
same as above but you then you add the ID not by using the Edit Columns... task but simply by adding a new column to the dataview itself (click into first column of the DataView, right click and choose Insert...Column to the left) and injecting the ID manually. Easiset way to do that is to copy one of the other fields and then changing its databinding to point to the ID field.

Wednesday, November 5, 2008

People Search for WSS

Recently I attended a presentation by Ken Biswell from RedVespa and totally fell in love with their approach to People Search. He was presenting at the Wellington SharePoint Usergroup giving us insider tips and tricks for how to tackle a SharePoint project from the Business Analyst point of view and it was a great session.
So what was their approach to People Search? Simple! They generated WCMS driven profile pages which make it easy to update and copy/paste whole CVs into and created a separate content source which only indexes those pages. Thus the PM who is now looking for a person with a specific skill like ITIL or SCRUM can simply search the limited content source and get only the results that interest him/her without being bombarded with irrelevant results.
Simple, elegant and most importantly effective! Saving time keeping profiles up to date and saving time searching for key people.

Enabling WSS for Enterprise Search

Often when I present to my students the features of the search in WSS and the features of the search in MOSS I get the question "any chance we can have a free version of enterprise search in WSS?" And thanks to Microsoft the answer is yes!

With Microsoft Search Server 2008 Express it is a doddle to get enterprise search up and running in your organisation. It comes bundled with the core WSS features so you can install it onto a WSS box or have it standalone. The standalone option is great for scalability as you can dedicate the server for indexing and serving search queries.

What is included that the MOSS boys have already?
  • best bets: define the perfect searchr esult for specific keywords
  • keywords: define multiple synonyms for a keyword so abbreviations also get to the correct resutls
  • authorative sources: specify who's hot and who's not in your search results
  • federated search: a great workaround for searching the BDC
  • security trimmed results: Only see the results you really have access too.
  • Query and Results reporting: find out what your users are searching for and what results they were receiving. Great for optimising the keywords to better serve your seekers.

What's missing that the MOSS boys have?

  • load balancing for search, crawling and indexing
  • People search
  • Business Data Catalog Search
  • More API options to customise search even more

What's the end result? If you have a spare windows 2003 machine with 1-2 gb of ram and a bunch of spare space for the index , hook it up to the network, install search server 2008 express within minutes and start searching your sharepoint content, your existing intranet and internet and even you sql databases and favourite RSS feeds.