Web Statistics - Google Analytics

High quality, advanced, user friendly and FREE web statistics for small and medium size web sites then I think Google Analytics is THE tool! Check i out on www.google.com/analytics


Creating filtered lookup fields in SharePoint edit forms

Yes - it is possible - even without coding! Using SharePoint designer you can create custom looukup fields where you set your own filter on which elements from the source list which you want to display. What we will do is to insert our own drop down list instead of the standard lookup field. This drop down will fetch its values from a new data connection.

Below is the steps to follow.
  1. Define your list with all the needed fields and lookups
  2. Create a new custom form(s) - you will need a new New and Edit form. For details see this blog entry.
  3. Delete the existing List Form web part
  4. Add a Custom List Form to your page
  5. Create a new Data Source to use to get and filter your lookup data
    • Open the Data Source Library
    • IF your lookup list is NOT in the same site as your main list do the following
      • Select Connect to another library (at the bottom of the Data Source Library window)
      • Click Add
      • Browse to the web site which contains the list with your lookup values
      • Add a name to your source
      • Click OK
    • Find your list either in Current Site or the site added above.
    • Right click on the list that will be your lookup source and select Copy and Modify
    • A Data Source Properties dialog will be display
    • Select the Fields you need
    • Select the Filter you want to apply
    • Select Sort to set the correct sorting order
    • Click OK
  6. Give your new datasource a name; FilteredDS (or something else :-))
  7. Delete the SharePoint:FormField which controls the existing lookup
  8. Insert a SharePoint Drop Down List Control
  9. Set the parameters of the drop down list
    • DataTextField="MyTitleColumnName"
    • DataValueField="ID"
    • SelectedValue="{@MyListLookupParameter}
    • Id="THEID" - the same as the ID of the FormField just deleted
    • DataSourceID="FilteredDS"
    • __designer:bind="{ddwrt:DataBind('i',concat('THEID',$Pos),'SelectedValue','SelectedIndexChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@MyListLookupParameter')}"
  10. The last step is to set your new input form as default form to use when elements in your list is either edited or created. Right click on the list (in the Folder List) you are customizing and select propertes.
  11. Save, test and debug!

It is important to get all the steps right, but step 10 takes care of posting the data back to the list.

Thanx to Dattard Zebug - which was the primary source on solving this challenge.

Issues and error sources:

  • Suddenly the data source is not recognized any longer and you get a server error. SharePoint designer had added a '0' after the ID of my datasource name. Why? Ask Microsoft.

To create a cross-site lookup field do the following

  • Create the list that you want to be the source of your lookup field - must be deone at the site collection root.
  • Create a new Site Column (at the site collection root as well ) which you define as a lookup field and the liste created above as your source
  • Use the new site column field in your new list - anywhere in the site collection

A lot of the limitations with the lookup field should hereby been solved and addressed - at least for the time being :-), Unfortunately no C# code was needed :-)

SQL Server 2005 Reporting Services and SharePoint integration

I've just demoed the BI capabilities in SharePoint 2007, SQL Server 2005 and Excel 2007 - a very powerful team of tools. The recently released SQL Server 2005 Service Pack 2 and the integration between SharePoint and Reporting Services was included.

The Reporting Services SharePoint integration mode advantages:

  • Single consistent user interface for reports administration and presentation
  • Rich user in experience
  • Reports stored as any other document in SharePoint and therefore standard SharePoint features are available; workflow, report versioning and collaboration.
  • Reports stored in SharePoint, but synconized with the reports executed from the server. Scheduling, caching and subscriptions still stored in the report server database.
  • Single securtiy model
  • Standard reporting filtering through web parts and filters
  • Common storage for reports, data sources and report models
  • Publishing, viewing and managament through a familiar SharePoint user inteface
  • Enables organisations to construct BI dashboards

Resports can be created either through Visual Studio (by a developer) or by online tools (end user.

Important concepts:

  • Report Model. Defines the data soruce(s) of a report, the security parameters for the data soruce, tables, fields and releationships for the model. The report model is published to a library in SharePoint.
  • Report Builder. The tool used by the end user to create new reports. Deployed using ClickOnce, and installed automatically on the client workstation.
  • Report Viewing. Reports are displayed either in a web part or opened directly in the browser window.

Reports are managed from extra menues supplied with the report library template;

  • View properties (cataegories, teimstamps, approvales, etc)
  • Edit properties (meta data, etc.),
  • permissions
  • Edit in report builder
  • Delete
  • Manage subscriptions (add, edit and delete report subscriptions, automatic notifiactions sent to useres when reports are changed)
  • Manage data Sources. Share the same data source definition among multiple reports.
  • Manage parameters. Manage values and parameters passed into the report.
  • Manage processing options. Choose processing, snapshot and timeout options.
  • View report history
  • Check out/in, versioning, send to, version history, alert me - all standard SharePoint features.

Installation and configuration step by step, by Liam Cleary.


Customizing and/or extending or customizing existing standard field controls

There are errors in the DateTimeField control in SharePoint. It crashes when you set either the DateOnly or the TimeOnly fields. We wantet just the date so I had to make a small adjustment and make MyDateTimeField control with two extra properties MyDateOnly and MyTimeOnly, and override the RenderFieldForDisplay() method. I just rendered the DateTime value myself! 3-4 lines of code only!

This article gave me the ideas neccesary to "tweak" and fix errors in the standard field controls provided by Microsoft: Stefan Gossner

Here is my code:

public class DatoFormatFieldControl : Microsoft.SharePoint.WebControls.DateTimeField
public bool DateOnly

if (ViewState["DateOnly"] == null){return false;}
return (bool)ViewState["DateOnly"];
{ ViewState["DateOnly"] = value; }

protected override void RenderFieldForDisplay(
HtmlTextWriter output)
if (DateOnly)
() + " " + ((DateTime)


Creating custom forms for sharepoint lists using SharePoint Designer

Yes, we all have to face it (sooner or later): SharePoint designer IS a great tool - the tool - to customize SharePoint applications! We (as programmers) DO NOT need to write invent the wheel again, and again, and again.... SharePoint Designer AND Visual Studio 2005 (and C# programming) will be OUR tools.

So, how do we create a customized form to register our data in a list? Follow these steps:

  1. Open the site in SharePoint designer where the list is located and navigate to the list
  2. Make a copy of the newform.aspx and name it mynewform.aspx
  3. Open mynewform.aspx in the designer in html view
  4. Select the ListFormWebPart and delete it
  5. Select 'Insert Sharepoint controls Custom List form'
  6. Add design elements, move things around, delete fields, etc to create the form as you would like it.
  7. Save it.
  8. Right click the list name in the folder list and select Properties
  9. Select the 'Supporting files' tab
  10. Select Item in the 'Contenty type specific forms' list
  11. In the field 'New Item Form' browse to mynewform.aspx
  12. Select 'OK'.
  13. Browse to your list in the web browser, select New and your mynewform.aspx should be the form that is used

Other articles:

Error sources and issues when writing Custom Field Types

These are issues and problems I've run into when writing my custom field types:

  1. 'Field type is not installed properly' error. When writing Custom Field Types it is important that the TypeName field in the fldtypes_xxx.xml file corresponds with the class name that actually implements your field type. Typos, renaming, and keeping implementation in sync with the xml-definition file(s) has been my "issue".


Migrating EPiServer projects from .NET 1.x til .NET 2.0 and from VS 2003 til VS 2005 Web Application projects

I belived should be pice of cake, but I was wrong. I quickly got the error "Parser Error Message: Ambiguous match found. " when trying to run the final project. I took me a while - and some "googling" - to discover the problem source: a region was named 'MainRegion' in the defaultframework.ascx file and a variable in the codebehind was named mainRegion !?¤!&#"¤%!.

Other error sources to be aware of:

  • Naming conflicts between your registeres user controls on a page and other variables on the same aspx page OR in the user control itself. Resolution: Rename all your user controls in the Register statement, for example, use the 'ux' prefix.

Other tasks:

  • The language files are not updated automatically, and have to be copied/updated manually.
  • Copy all the new template files intot the new project library (aspx, ascx and cs files). Make sure you don't overwrite your own customizations.
  • Set the correct namespaces - search and replace - but has to be done :-)

Articles you should take a look at BEFORE you start the migration process:

Creating and using CAML Queries

To query SharePoint for data you need to write CAML queries. Complex queries are not easy to write, and therefore you are in a strong need for good tools. Lucky for you AND me there are a couple of these around which you just have to have:

  • U2U Caml Builder - on the web. Link here.
  • STAMIT's Caml Viewer - on CodePlex. Link here.
  • Tips & tricks working with CAML queries. MSDN article ; Operators s null = IsNull, is not null = IsNotNull, etc.

Those 2 tools are good companions. Without tools like these writing the right queries is an error prone challenge, but now .... its much simpler and quicker!

A simple CAML query that is easy to write, but even easier to extract using the mentioned tools:

System.Text.StringBuilder sbQuery = new

sbQuery.Append(" <OrderBy>");
sbQuery.Append(" <FieldRef Name=\"Sortering\" />");
sbQuery.Append(" </OrderBy>");
sbQuery.Append(" <Where>");
sbQuery.Append(" <Neq>");
sbQuery.Append(" <FieldRef Name=\"Page_ID\" />");
sbQuery.Append(" <Value Type=\"Number\">" + properties.ListItem["ID"].ToString()
+ "</Value>");
sbQuery.Append(" </Neq>");
sbQuery.Append(" </Where>");

string sResult = sbQuery.ToString();
SPQuery q = new SPQuery();
q.Query = sResult;

SPListItemCollection val = list.GetItems(q);

Using IsNotNull:

sbQuery.Append(" <Where>");
sbQuery.Append(" <IsNotNull>");
sbQuery.Append(" <FieldRef Name=\"MyField\" />");
sbQuery.Append(" </IsNotNull>");
sbQuery.Append(" </Where>");


Saving/storing Outlook 2003/2007 messages and attachments in a SharePoint library

SharePoint is absolutly not perfect when it comes to e-mail administration. There are several limitations when it comes to storing e-mails and e-mail attachments from Outlook:

  • Attachments are NOT saved in the library automatically - you have to remember to save it with an *.msg extension
  • You ar not prompted to fill inn mandatory fields defined on the list

Read more in SharePoint 2007 Better For Managing Outlook Messages?


Migrating content from Microsoft CMS 2002 (MCMS 2002) to SharePoint 2007 results in a "Attempted to read or write protected memory" error

I've been working on a case where we should migrate content from a Microsoft CMS 2002 (MCMS 2002) database to the new SharePoint 2007 solution. We quickly run into a severe an unrecoverable error, "Attempted to read or write protected memory", when the migration procedure in SharePoint where trying to export data from the CMS 2002 database.

Microsoft Support identified the error and came up with a work-around;
  • Set the UserSid column in the AEUser table in the CMS 2002 database to null
  • Run the migration proceudre from SharePoint Administration again.

It worked! Well done Microsoft.


Creating Custom Actions

Follow these steps to create custom actions and make them available in SharePoint Designer and in the SharePoint solution(s):

Writing your action:
  1. Start writing your action; inherit from the the Activity class
  2. Define your static Dependency Properties that points to your public properties
  3. Override the Execute method
  4. Compile it: MyNamespace.MyActivity
  5. Assign a strong name to your library

Distribute your library:

  1. "GACC" your assembly - or assemblies. Your activity my relay on other assemblies and then these must be added ass well. Add the same assemblies to the SafeControl section in web.config.
  2. Add your library to the authorizedTypes section in the sharepoint application web.config
  3. Make your activity available to SharePoint designer by adding it to the \12\template\1033\workflow\wss.actions file, and placing your action definition inside the Action section
  4. Reset IIS

Of you go:

  1. Open SharePoint designer
  2. Select your activtity and add the defined parameters.
  3. Great!!! .... hopefully ... debug!

Articles with more details:

Possible errors with solutions:



Small things that is important to remember

1) If you want to add custom inline code in your master pages or page layouts:

  • Add the following line to your web.config file
  • <pageparserpaths>
  • <pageparserpath includesubfolders="true" allowserversidescript="true" compilationmode="Always" virtualpath="/*">
  • </pageparserpaths>
  • Mike Walsh

2) Add som inline code to switch master pages, for example, if you want to switch to printer friendly master page:

<script language=CS runat=server>

protected override void OnPreInit(EventArgs e)
SPWeb myWeb = SPControl.GetContextSite(Context).OpenWeb();
string strUrl = myWeb.ServerRelativeUrl + "/_catalogs/masterpage/print.master";
this.MasterPageFile = strUrl;


More code
Serge van den Oever


Windows Communication Foundation

Well, this is not a SharePoint specific technology, but important to any application that will "live" in the "connected society". Here are some tips on where to start if you are new to WCF:
  • WCF 101 . From description of what WCF is, an HelloWorld example, to....

Business Intelligence, reporting and analysis in Office 2007

Writing a presentation and creating some demos of the cababilities with combining Windows SharePoint Services and SQL Server 2005 Reporting services, Excel 2007, Excel Services 2007 and SQl Server Analysis Services I used the following sources to get me going:

It's a lot!!!


WSS 3.0 Administration Tips & Tricks

Check out these tips & tricks

Security in SharePoint 2007

The following link on TechNet, "7 New Features That Enhance Security in SharePoint", explains the new security improvements in SharePoint 2007:
  • Pluggable Authentication Provider
  • Forms based authentication wnd web based SSO
  • Encrypting connection strings
  • Alternate Access Mappings and Zones
  • Target content for secure collaboration
  • Integrated pluggable SSO
  • Information Rights Management (IRM)


Checklist with tips on how to write Custom Web Controls

When writing web controls make sure that you have done the following:

  • Assign your controls values the CreateChildControls event and ONLY there. I they get their values in the class declaration they will be reset every time the page loads (on postbacks)
  • Make sure that you inherit from the INamingContainer - if not you may not be able to pick up all events correctly (e.g. button clicked events)

More to come ...


Customizing My Site

As I was about to customize My Site - by changing the onet.xml - I came across an article by Steve Peschka (SharePoint Rangers Team). Good for me! :-) It is not recommended to ever change the onet.xml when making changes to My Site (unsupported state, issues when upgrading to later versions, etc) and how the private view of My Site is provisioned. Features (and more features), master pages and custom server controls is the way to do it in 2007.

These are the recomended steps that should bring you home safe:

  1. Create a new master page to be used for your my sites.
  2. Create a feature that runs a code snippet that directes SharePoint to use your new MySite master page instead of default.master
  3. Add a feature stapler feature which will run your my site master page feature when a new My Site has been created. Not only does this feature set the new master pages, but also other properties needed to control the behavior and logic in the custom web control (see step 4)
  4. Add your own custom server control to your my site master pages. This control will be responsible for adding and changing web parts to your my site (the private view)
  5. The public view of my site may be changed in SharePoint designer. Open the page http://mysitehost/person.aspx?yourdomain\username

And when I had done a lot of work I found this great release of a My Site Create customization solution on CodePlex. You will find it here. Written by Steve Peschka with others.

I'm currently adding new customization elements, such as:

  • adding and removing navigation elementes
  • adding and removing lists
  • adding list items to lists
  • etc.

It will grow with time as the requirements for customization changes.