21 September 2009

SharePoint Development Solution End-To-End

Over the next few weeks I plan on putting together an end-to-end solution that I've been working on for one of our internal clients. The goal is to demonstrate some of the things that I've learned (and continue to learn) while building a solution for SharePoint. I welcome feedback and tips as I'm sure there may be better ways to accomplish some of my goals.

The project is to build a document management system for the authoring and distribution of Information Technology Knowledge Base Articles using SharePoint and Microsoft Word. These articles will be linked to a custom in-house ticket management system. We must also move over 400 existing articles into the SharePoint site and attach the appropriate metadata.

The current system works well for simple tasks, but when assembling complex documents with screenshots, tables and reports, the current system can be limited and cumbsome. For documents that will contain screenshots or images, the author must prepare all of their screenshots or images ahead of time, upload them to the system and then create the links to those images in the current system. While this process works, the workflow is very cumbersome and takes more time than it should.

Here are the primary goals of this project:

  1. Leverage SharePoint Document Authoring, Workflow, Search and Metadata for the creation and management of Knowledge Base Articles
  2. Define and collect required metadata for KB documents to make key information available for previewing.
  3. Standardize document creation process by using a predefined template.
  4. Maintain existing documentation and update links from the work orders to the knowledge base articles.
  5. Synchronize categories between existing system and SharePoint and keep them up-to-date.
  6. Leverage SharePoint Search Web Service to find and link KB documents in SharePoint to work orders.

To create the solution, I will be using WSPBuilder to create and maintain my feature. This Codeplex project does much of the heavy lifting of preparing and deploying the solution package. I have decided to deploy a feature as the current internal work order system may eventually be used by multiple internal clients to manage their work orders. By deploying the SharePoint side of the project as a SharePoint Solution (wsp), any existing or new sites in SharePoint can be made a container for Knowledge Base Articles. I had considered just creating a site definition and adding it to SharePoint, but I would rather have the option of either creating a new site or extending an existing site to contain these items. If I had decided to do a site definition, I would only be able to create new sites and would be unable to extend the current site collection.

To start this series, I created the layout of my feature in Visual Studio 2008. In visual studio, I created a new WSPBuilder Project. This project template is installed with the WSPBuilder project from Codeplex. The new project template will create a new project with a signing key, the 12 hive root folder and a solutionid.txt file. On the 12 hive, I created the TEMPLATES and FEATURES folders. These are the folders in the 12 hive that contain all of the configuration information for SharePoint. Inside the features folder, I added my custom folder (KBRepository) that will contain the XML definition files for my custom feature.

When done, my folder stucture appears as follows:

  • Solution
    • VS Project
      • 12
        • TEMPLATE
          • FEATURES
            • KBRepository
    • KBRepository.snk
    • solutionid.txt

Inside the KBRepository folder, I added the Feature.xml file that will contain the definition of my new feature. To make authoring the XML file a little easier, locate Schemas in your Properties window and click the ellipses. Click Add and then navigate to your 12 hive/TEMPLATE/XML and click on wss.xsd. Visual Studio will now provide intellisense to help define the feature. Here is the feature definition:


<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Scope="Site"
Creator="Software Development"
Id="386CF027-6AC7-460a-A7D6-4E503B2B6293"
Description="Sets up this site collection to author and manage KB Articles"
Title="KB Repository"
Version="1.0.0.0">
<ElementManifests>
<ElementManifest Location="KBItemFields.xml"/>
<ElementManifest Location="KBContentTypes.xml"/>
</ElementManifests>
</Feature>

Notice I have two element manifest files. These two files will be used to create site columns and content types that will be used by other parts of my solution. The KBItemFields.xml and KBContentTypes.xml files were also created in the root of the KBRepository folder.

I opened KBItemFields.xml and added the following XML. (Remember, if you click on Schemas and associate the wss.xsd you'll get intellisense support).



<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID="{B180626E-4DD1-44ca-9157-00639A0945DA}"
Name="WSSAPPDEV_CategoryID"
StaticName="WSSAPPDEV_CategoryID"
DisplayName="Reference Category ID"
Type="Number"
Min="0"
Decimals="0"
Commas="false"
LCID="1033"
Indexed="false"
Group="Category Columns"/>
<Field ID="{58AD2A67-B08C-4803-956F-82F425201D6B}"
Name="WSSAPPDEV_CatDescription"
StaticName="WSSAPPDEV_CatDescription"
DisplayName="Category Description"
Type="Note"
NumLines="5"
LCID="1033"
RichText="false"
Indexed="false"
Group="Category Columns"/>
<Field ID="{793E8479-066B-41be-B494-0D4207B8BD0A}"
Name="WSSAPPDEV_Active"
StaticName="WSSAPPDEV_Active"
DisplayName="Active Category"
Type="Boolean"
LCID="1033"
Indexed="false"
Group="HICUP Category Columns"/>
<Field ID="{A4F4E2EA-80CB-4a16-ACC5-060E922EB06C}"
Name="WSSAPPDEV_CustomerCat"
StaticName="WSSAPPDEV_CustomerCat"
DisplayName="Customer Category"
Type="Boolean"
LCID="1033"
Indexed="false"
Group="Category Columns"
/>
<Field ID="{DFE30371-501F-4dd3-B11A-54C762AFEE09}"
Name="WSSAPPDEV_Keywords"
StaticName="WSSAPPDEV_Keywords"
DisplayName="Keyword List"
Type="Text"
MaxLength="1000"
Indexed="true"
LCID="1033"
Group="Knowledge Base Columns"/>
<Field ID="{C486FB10-F649-476a-8606-495F900DD383}"
Name="WSSAPPDEV_ReviewDate"
StaticName="WSSAPPDEV_ReviewDate"
DisplayName="Review Needed Date"
Type="DateTime"
Format="DateOnly"
Indexed="false"
LCID="1033"
Group="Knowledge Base Columns"/>
</Elements>

Now in the KBContentTypes.xml, I provided the following XML:


<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- CATEGORY -->
<ContentType ID="0x0100aa4bb14f2f8746db941ef9b5e52b4cDF" Name="KB Category" Description="A category contained in the KB system"
Group="KB" Hidden="FALSE" Version="1">
<FieldRefs>
<FieldRef ID="{B180626E-4DD1-44ca-9157-00639A0945DA}" Name="WSSAPPDEV_CategoryID" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE" Required="TRUE" ShowInNewForm="FALSE" />
<FieldRef ID="{58AD2A67-B08C-4803-956F-82F425201D6B}" Name="WSSAPPDEV_CatDescription" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE" Required="FALSE" ShowInNewForm="FALSE"/>
<FieldRef ID="{793E8479-066B-41be-B494-0D4207B8BD0A}" Name="WSSAPPDEV_Active" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE" Required="TRUE" />
<FieldRef ID="{A4F4E2EA-80CB-4a16-ACC5-060E922EB06C}" Name="WSSAPPDEV_CustomerCat" ShowInDisplayForm="TRUE" ShowInEditForm="FALSE" Required="TRUE"/>
</FieldRefs>
</ContentType>
<!-- KNOWLEDGE BASE -->
<ContentType ID="0x010100aa4bb14f2f8746db941ef9b5e52b4cF0" Name="IT Knowledge Base Article" Description="Knowledge Base Information Article for KB"
Group="KB" Hidden="FALSE" Version="1">
<FieldRefs>
<FieldRef ID="{DFE30371-501F-4dd3-B11A-54C762AFEE09}" Name="WSSAPPDEV_Keywords" Required="TRUE" />
<FieldRef ID="{C486FB10-F649-476a-8606-495F900DD383}" Name="WSSAPPDEV_ReviewDate" Required="TRUE" />
</FieldRefs>
</ContentType>
</Elements>

I'm ready to deploy and test my budding solution. If you right click on the project node in your solution explorer, there is a new WSPBuilder Menu. From this menu, select Deploy and it will deploy to the SharePoint instance on the local machine.

Upon successful deployment, navigate to site and activate the feature by going to Site Actions > Site Collection Features and choosing to activate the feature. The feature has been scoped as Site, so this places it into the Site Collection Features. After activation, the new site columns and content types have been added to the root level of the site.

Congratulations, you have successfully built and deployed your first feature to SharePoint. In my next installment, I am going to create a feature receiver and programatically create some new lists to contain the categories and KB documents. I will also create a site column that performs a lookup into my category list and add the new site column to the IT Knowledge Base Article content type.

15 September 2009

BDC Application Definition Designer ShowInPicker Quirks

Today I was doing some work using the BDC Application Definition Designer for SharePoint 2007 and discovered some very odd behavior. My current project has me defining a business data catalog that points to our help desk work order system to gather categories for a list of knowledge base articles. I completed the design of my BDC application and deployed it into SharePoint, created a new column in my document library to pick the desired entity only to get the message "There are no Business Data Types loaded in the Catalog". Oddly, the data type was there prior to changing a single property on one of my type descriptors: ShowInPicker.

I had set this value on the name of the category since the default item displayed in the picker is the identifier of the entity. It is very difficult for users to pick a category when all that is displayed is a series of numbers, thus driving me to set the value of ShowInPicker to true for my category name field. So, I examined the XML created and discovered:

<TypeDescriptor TypeName="System.String" Name="CategoryName" DefaultDisplayName="Category Name">

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">Category Name</LocalizedDisplayName>

</LocalizedDisplayNames>

<Properties>

<Property Name="ShowInPicker" Type="System.Boolean">true</Property>

</Properties>

</TypeDescriptor>

I remove the line and imported the definition once more. Now my business data type showed up again. After searching, I discovered an article by Paul Galvin describing how to set the ShowInPicker value. In his article, I discovered another property that I wasn't including in my definition: DisplayByDefault.

I went back to the Application Definition Designer and added this under the properties node for my category name and exported the LOB definition. Again, I imported this into SharePoint and received the same error message - "There are no Business Data Types loaded in the Catalog". Upon exploration of the XML, I discovered the following:

<TypeDescriptor TypeName="System.String" Name="CategoryName" DefaultDisplayName="Category Name">

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">Category Name</LocalizedDisplayName>

</LocalizedDisplayNames>

<Properties>

<Property Name="ShowInPicker" Type="System.Boolean">true</Property>

<Property Name="DisplayByDefault" Type="System.Boolean">true</Property>

</Properties>

</TypeDescriptor>

The new property had been added, but the order was different from Paul's, so I changed the order and imported the definition again. This time, everything worked as properly and I could view the category name in the picker.

Moral of the story: Use the Application Definition Designer to get you started in defining your BDC application definition and then go back to make tweaks like this by hand.

03 February 2009

Online Study Group for Seamless Teamwork

Only 2 Days to Go Until the Seamless Teamwork Online Study Group. From the shores of Sydney Australia (well, the City actually, not the beach!), I’m already thinking ahead a couple of days for when the Online Study Group for Seamless Teamwork will kick off. It is appropriate that I think this way, because I’m in Sydney today (and was in Melbourne Australia yesterday) to deliver 4 face-to-face editions of the Seamless Teamwork seminar for corporates. Read More on EndUserSharePoint.com.

15 September 2008

Free Online Seminar on SharePoint Dashboards

Mark Miller at EndUserSharePoint.com is hosting a free 1 hour presentation on SharePoint dashboards. This presentation is targeted towards end users, but I would recommend that developers take some time to check it out. It is simply amazing what the end-user is empowered to do in SharePoint, and it may help you with ideas for your projects. The presentation is scheduled for 1pm EST, Tuesday (that's tomorrow). I recently attended one of Mark's presentations, and you will not be disappointed. He is an excellent communicator and does a great job of educating you in SharePoint. Visit http://www.endusersharepoint.com/?p=785 for more details.