Saturday, September 29, 2007

Using PeopleEditor as a Template Field

Hi!

When a customer of mine wanted a web part and described how it was supposed to work, there was a need to use the PeopleEditor class and use it insida a template field in a SPGridView. There are a lot of ways to accomplish the following task, but I choose to use a DataTable as the datasource for the gridview.

The SPGridview has four columns, a generated edit-column and three template fields. One of the template fields consists of a Literal control when displaying the item and a PeopleEditor when in editing the item. The problem was to set the default value of the PeopleEditor to a value that resides at a specific location in a specific list. The value in the list is of the type Person.

Trying to use the PeopleEditor.Accounts.Add() methos did not work and after closely looking the the SDK for the PeopleEditor class, there can be seen that the method CommaSeperatedAccounts property could be set. And after putting the value from the list (the Person column) into the PeopleEditor.CommaSeperatedAccount property the template field was showing the default value from the item view in the edit view of the SPGridview.

The documentation of the PeopleEditor is very shortcoming and perhaps this will be of some use to someone.

//Sebastian

Posted by Zeb at 18:29:10 | Permanent Link | Comments (5) |

Wednesday, September 19, 2007

Using KPI-lists with advanced filtering

Hi!

A customer of mine wanted a KPI list with values originating from a SharePoint list which already exists. The customer already have a KPI list with a few dozens of indicators which were quite easy to make. However, this new KPI list was to be using a more advanced filter for the SharePoint list.

The underlying list have several column where one of these columns contains persons. The indicators in the KPI list are to be made for list items where person column only has values and then grouped together with another column. The main problem here is to make the view where only the desirable list items is shown. When trying to make the indicators from the list one will discover that there is no way of getting only the list items where the person column contains some value. Hence a try in SharePoint Designer was made. Here the new view of the list could be extracted, but only after the listview web part had been converted into a Data List Web Part and the KPI list indicators didn't seem to like that since I didn't get it to work.

The solution was to make a small console app that changes the view of interest by modifying the Query property of the SPView object with a caml query like this one:

<Where><IsNotNull><FieldRef Name='Column_Name' /></IsNotNull></Where>

After updating the view and going back to the browser, the view have changed and only displaying the list items where the column, in the example above named Column_Name, have values.

There are many other syntaxes that can be used with caml queries and Patrick Tisseghem has made a very useful application called CamlBuilder.

Hope this help someone.

//Sebastian

Posted by Zeb at 21:33:40 | Permanent Link | Comments (1) |

Thursday, September 13, 2007

Timezones and SharePoint

Hi!

A customer of mine wanted to make sure that users in different time zones always has the local time shown when looking at items in document libraries, lists etc. Beforehand we knew that SharePoint sites have their own regional settings, independent of the SharePoint server regional settings. But this was not enough. Let's say that an project site has members that is scattered all over the world, how is the regional settings supposed to be configured?
The answer was easier than expected. None of us knew that, at least in SharePoint 2007, each users can have their own regional settings. The regional setting is reached if clicking on the "Welcome <loginname>"-dropdown in the top right corner of SharePoint. Select My Settings and you are redirected to a page with a toolbar that looks like this:

 

Here the user can change her/his own regional settings by clicking on the My Regional Settings link. Here the user have the choice of either keeping the regional settings of the web site or making her/his own regional settings.

 

The effect of this change is immidiate.
It might be a good idea to make a small javascript that compares the local time zone with the timezone in SharePoint and if there is a difference pop up a message that says something like, don't forget to change your timezone. This is only a precation since it is quite easy not to remeber to change the regional settings in SharePoint after setting the clients timezone.

//Sebastian

Posted by Zeb at 14:58:16 | Permanent Link | Comments (2) |