Wednesday, August 19, 2009

Web Parts – a developer and architect’s guide

Below are the slides from the presentation that I did in the SharePoint Saturday events in Sydney and Adelaide in the last two weeks. A lot of people asked me for it, but I am not sure how much help it can be to you if you haven't been there- since my presentations are more me talking and running demos, and less information from slides (I do love the sound of my own voice...).

If you still want to, here are the slides:

















Oh - and credit to Fernando Felman for the wonderful list of links at the end. Here they are if you want to copy them:
http://en.wikipedia.org/wiki/ACID
http://www.codeplex.com/AppArchGuide
http://www.codeplex.com/AppArch
http://www.martinfowler.com/

Tuesday, August 18, 2009

Windows 2008 R2 goodness - adding sharepoint folders to a library

Just a heads up to what you can expect when you upgrade to Windows Server 2008 R2 (aside from all the technical things like virtualization improvements):

Win2008R2 is also known as “Windows 7 Server”, since the UI is windows 7 (unlike windows 2008 which was vista).

This means we can create “libraries” – which are virtual folders which replace the vista “search folder” with much more options.

An example is shown below – I created a virtual folder called “sharepoint files” and added the 12 hive and the office servers folders as well as the “logs” folder – and now I have an easy way to get to all three of them in windows explorer:
Bliss. Oh - can you see how I named my 2008 R2 machine?

Sunday, August 02, 2009

Creating Thesaurus files

I had a look at the excel file that Mauro Cardarelli wrote as a tool to generate thesaurus plans. While the tool is nice, I was dissapointed it did not include a facility to load an existing XML file and analyze it to see if it contains faults such as duplicates.

So what I did was write my own macro that loads a thesaurus file into Mauro's excel spreadsheet. The macro only loads expansions (as his spreadsheet does not deal with replacements) - but you can easily change it to load replacements if you want.

To use this macro, open Mauro's file, and open the visual basic window (alt-f11) and paste the procedure at the bottom of the "sheet1" module. To run it, either click the "run macro" button in excel, or from the VBA environment, hit F5 when the cursor is in the procedure. The macro will ask you for the path of the file, and will load it and populate the excel file.

Sub LoadThesaurusFile()
    Dim total As Integer
    total = 0
    Dim thesaurusFile As New DOMDocument
    Dim path As String
    path = InputBox("Path to the Thesaurus xml file", , ActiveWorkbook.path + "\thesaurus.xml")
    If (path = "") Then Exit Sub
    
    thesaurusFile.async = False
    thesaurusFile.validateOnParse = False
    'to avoid errors because of a thesaurus schema file, we will load the file as a text file, and then remove the schema reference
    Dim fs As TextStream
    Dim fso As New FileSystemObject
    Set fs = fso.OpenTextFile(path, ForReading, False, TristateUseDefault)
    s = fs.ReadAll
    s = Replace(s, "xmlns=""x-schema:tsSchema.xml""", "")

    Dim sht As Worksheet
    Set sht = ActiveSheet
    If (thesaurusFile.LoadXML(s)) Then
        Dim expansions As IXMLDOMNodeList
        Dim expansion As IXMLDOMNode
        Set expansions = thesaurusFile.FirstChild.SelectNodes("//expansion")
        'start from row 4
        Dim iCurrentRow As Integer
        iCurrentRow = 4
        'loop over the expansion tags, and populate the spreadsheet
        For i = 0 To expansions.Length - 1
            Dim iCurrentColumn As Integer
            Dim subs As IXMLDOMNodeList
            'load current exapnsion
            Set expansion = expansions.Item(i)
            'load the expansion subs
            Set subs = expansion.SelectNodes("sub")
            For iCurrentColumn = 0 To subs.Length - 1
                sht.Cells(iCurrentRow, iCurrentColumn + 1) = subs.Item(iCurrentColumn).Text
                total = total + 1
            Next iCurrentColumn
            iCurrentRow = iCurrentRow + 1
        Next i
        MsgBox ("Total entries: " & total)
   Else
    MsgBox ("Error loading the XML file: " + x.parseError.reason + vbCrLf + "Source:" + x.parseError.srcText + vbCrLf + "Link:" & x.parseError.Line)
   End If
   Set thesaurusFile = Nothing
   
End Sub

Sunday, July 19, 2009

In memory of a great sharepoint guy

Hi everyone.
If you followed this blog last year, you would have seen the blog post about Lee Marriage's death. Lee was a collegue who helped run the SharePoint user group in Sydney, and had a very useful sharepoint blog, and was a great guy all around.
Lee died last year in the Sydney "City to Surf" run from a heart attack. This year his friends are all going to do the run (or in some cases the walk) in his memory - while raising money for the Heart Research Institute.
If you can, please sponsor us on the everydayhero site: http://www.everydayhero.com.au/lee_marriage_groupies and donate a bit of money. I don't really care if you sponsor me specifically or any other member of the team.
thanks!

Sunday, July 12, 2009

Setting the navigation options for a meeting workspace

This is just wierd. I had to change the navigation options for a meeting workspace using code on a MOSS farm. The meeting workspaces were all under a publishing site, with the publishing feature turned on, so the option to inherit the navigation from the parent site is available in the UI.
However, there is no option to set it in the API.
When dealing with publishing sites, you can easily set it by using the PublishingWeb object instead of the SPWeb object - but using PublishingWeb.IsPublishingWeb on the event workspace returns false.
So I had a look at the code that runs when you click OK on the navigation settings page - and guess what? Microsoft doesnt check if the site is a publishing web or not - they just assume it is, and set the properties! So I did the same, and the code runs great. It doesnt matter that it is not a publishing web.
Code:
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web); pubWeb.InheritGlobalNavigation = true;

Australian IT people - Want to learn about sharepoint?

SharePoint Saturday is coming to Sydney
This upcoming event (the 8th of August 2009 at the Microsoft Sydney Office) is going to be an awesome event with a lot of sessions - all about sharepoint. Think TechED - but only for SharePoint.

Join SharePoint architects, developers, and other professionals that work with Microsoft Office SharePoint Server 2007 for ‘SharePoint Saturday’, on Saturday, August 8th, 2009. SharePoint Saturday will be an educational, informative & lively day filled with sessions from respected SharePoint professionals & MVPs, covering a wide variety of SharePoint-orientated topics. SharePoint Saturday is FREE, open to the public and is your local chance to immerse yourself in SharePoint!
It is free, and there are many prizes (including my book), and if you come you can hear me talk about developing web parts - General Meeting: How to build real world web parts where I will demonstrate how to build a web part for SharePoint from scratch, and then will demonstrate some of the most elusive best practices that web part developers need to know.

Other sessions available are:
Building a Bulletproof SharePoint Farm; Disaster Recovery and High Availability for SharePoint
What SharePoint Administrators should know about SQL Server
Building Process Driven Applications leveraging SharePoint
ASP.Net and SharePoint
Content Deployment Bootcamp
Blooming SharePoint (SharePoint UI customizations)
Geographically Distributed Deployments for SharePoint
SharePoint as a platform for enterprise mash-ups
SharePoint Document imaging - The paper-laden office is here to stay
MOSS 2007 – Architecture best practices from the field
SharePoint Designer: Working with the DataView Web Part
Leveraging SharePoint Web Services

This whole event was organized by my friend Brian Farnhill - who has a great SharePoint developer blog that you should check out if you didn't already, and by fellow MVP Ben Walters - also a great guy all around.

Wednesday, June 24, 2009

Error message when checking in a document from office 2003

In a custom solution I recently worked on we were receiving an error from office applications when we tried to check in documents from within office 2003 applications like word or excel. The error was: "Cannont perform this operation. The file is no longer checked out or has been deleted" After a lot of digging, I found that the fault was in the custom content types that we deployed as features. The problem was that the person who wrote the CAML for the content types that inherit from the "Document" content type thought (understandably so) that it is enough to specify only the fields that the custom content type adds on top of the built in column. This meant that the content type did not have the right columns for file name for example. This was ok in the web UI or in office 2007 - but office 2003 must have some hard coded references that it missed, and it kept throwing errors. The solution was simple - add a reference to the built-in columns in each content type - even if it does inherit from the document content type. The following are the columns I had to add to solve the issue:

<!-- out of the box document columns--> <fieldref id="{5f47e085-2150-41dc-b661-442f3027f552}" name="SelectFilename"> <fieldref id="{8553196d-ec8d-4564-9861-3dbe931050c8}" name="FileLeafRef" required="TRUE"> <fieldref id="{8c06beca-0777-48f7-91c7-6da68bc07b69}" name="Created" hidden="TRUE"> <fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="Title" required="FALSE" showinnewform="FALSE" showineditform="TRUE"> <fieldref id="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" name="Modified" hidden="TRUE"> <fieldref id="{822c78e3-1ea9-4943-b449-57863ad33ca9}" name="Modified_x0020_By" hidden="FALSE"> <fieldref id="{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}" name="Created_x0020_By" hidden="FALSE">

So that solved it for the content types - if I added those content types to document libraries, there was no more issue of checking documents from office 2003. However, if you are adding the content types to the document library using either a feature (elements file with ContentTypeBinding) or using schema.xml, an incorrect character or binding in the xml files may also trigger the same issue. so beware!

Using the Today token in a CAML query

I just noticed today that the CAML creator application that I am using (by U2U) does not handle the today token properly (at least the version I have).
The Today token is used in views, when you want to filter on a date based on the current date. For example, if you want to set up a view that shows future events you set the filter on start date > "[Today]".

However, in CAML, you cannot use "[Today]" - the square brackets cause the query to break. Instead, you use "<Today />".
For example:
<Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'><Today /></Value></Geq></Where>

Tuesday, June 02, 2009

Read bits of my book in google

I just discovered that Google has bits of my sharepoint book that you can see for free- including the section on keyboard shortcuts (which I think is useful to print and put on the wall). Take a look (and feel free to write a review either there in google or here in the comments). The link is http://books.google.com.au/books?id=aJa4sjrHVLkC

Sunday, May 31, 2009

Easy links to remember for asking sharepoint questions

I hope this will be useful for someone - I made two tinyurls to help me (and others) remember the links to the sharepoint discussion forums in msdn. this way, all you have to remember is tinyurl.com and the text that I added:

SharePoint Products and Technologies Forums home page:
http://tinyurl.com/SharePointForums

SharePoint general questions forum:
http://tinyurl.com/SharePointForum

SharePoint development forum:
http://tinyurl.com/SharePointDevForum