Eamon Barker's eb.NET

Not quite vb.NET, but getting close!

Filter by APML
RSS Feed

Search

Profiles/Groups

Google Ads

Top Posts

Tags

Categories

Archive

Calendar

<<  September 2010  >>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Blogroll

Disclaimer

All postings are provided AS IS with no warranties, and confer no rights.

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright Eamon Barker 2010

CC License

Visitor Map

Locations of visitors to this page
Welcome to eb.NET... a place that I can keep the things that help me in my day, that might help you in your's!

SharePoint Development - Three Phases for Customisation

In this post I cover the steps I use when developing in SharePoint and when to use out-of-the-box functionally or custom code.

image

After a couple of weeks on holiday, I am back into it... and I thought I would get started with a post on the way I customise a SharePoint project. This post  won't cover coding or how to configure sites, but more of the philosophy behind the customisation of a deployment.

When I get a new project to sink my teeth into I generally split the customisation into three parts: Configuration, SharePoint Designer and Custom Coding.

The three phases

As I explained above, I use three phases when I do any customisation in SharePoint. Some projects may only need to use the first, some may need all three. Below is an explanation of each of those phases:

Configuration

Using SharePoint's out-of-the-box functionality you should be able to achieve between 60%-80% of the required customisation (or 100% if it is a less complicated project).

imageUsing Sites, Lists, Content Types, etc. you should be able to get a working example of a site. Usually this can be done with the users to ensure your requirements are correct and saves re-work later on.

I also find starting the build like this, you can let the project team loose on the site and as they get a feel for it they may move the requirements... it is better it happens at this stage, rather than on delivery when a lot more work has been done to the solution.

Once the initial configuration has been completed and a gap analysis has been done to determine what (if any) further customisation needs to be done you will need to crack open either SharePoint Designer (SPD) or Visual Studio (VS).

SharePoint Designer image

The next phase of any custom work I do requires SharePoint Designer (SPD). SPD is a tool that doesn't require masses of coding (VB.NET or C#) knowledge and can be used by technical BA's or skilled up power users. This doesn't mean developers can't use it as well!

I generally use SharePoint designer to:

  • Change the look and feel for the site
  • Display Cross-Site information in the Data View Web Part
  • Use SP Data source controls to populate ASPX controls
  • Do basic customisation of list views using the Custom List Form Web Part
  • Create basic workflows
  • Generally messing with the SharePoint Pages

Most of the time SharePoint Designer will get you close to the finish line. There are a few issues with it (not being able to easily move Workflows is one of them), but the good out-weights the bad!

Custom Coding (Visual Studio)

The third and final phase in any custom work is the cutting of custom code. The tool I use when customising a project in this way is Visual Studio. This is the realm of the developer and comes with all of the "extras" that go with full custom development (support, bugs, upgrade changes, etc.). But, VS allows you to really make the final changes to customise the project to 100% of the users requirements.

I use VSeWSS and other tools along with VS to do the following tweaks:

  • Create full site definitions so re-deploying the same site template is easy!
  • Create state machine and complex sequential workflows
  • Create custom Web Parts to modify and display information
  • Write event handlers to catch and process requests

and the list can go on and on... Where there are any gaps left after the first two steps, it should be cleaned up with code.

What to use and When

The size of the project generally dictates how far down the list you will need to go to get the solution you want. Below is a table that shows where you which direction you need to head:

Project Outline Skills Required Products to use
You are required to create a project management site that has the following functionality:
  • A place to store Risks, Issues, Communication Plans, Team Tasks
  • A place to store meeting information
  • A place to keep documents
  • A calendar to keep track of important events
  • A way to track tasks and view due/over due information
Knowledge of List & Site creation. This can be a Power User, BA, IT Pro or Developer. General SharePoint Configuration
You are asked to enhance the site with the following functionality:
  • A workflow that creates an unassigned task when an issue has been raised
  • A summary page displaying information on different phases of the project
  • Dashboard showing risk information using Red Light/Green Light indicators
SharePoint Designer Experience, HTML & CSS.
This can be a Technical BA, Web Designer or Developer
SharePoint Designer
The project team have used the site for several weeks and come back with the following enhancements:
  • A Web Part that shows statistical information about communications that have taken place. This Web Part is to be available to anyone to place on their personal page views
  • A workflow that produces an Office 2007 document with information from the issues & risk list to be used as a weekly report
VB.NET or C# programming skills & SharePoint development experience, generally this is the domain of a programmer. Visual Studio and any other development tools

Conclusion

Hopefully the above information will prove useful when deciding what path to take with customisation of your SharePoint project. If you have a large project that requires a fair bit of custom work, try and get the most out of SharePoint before you start using SharePoint Designer or Visual Studio... it is amazing what a little bit of planning and architecture can do! Anywhere from 60% - 80% of a large project can be completed without even opening SPD or VS.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SharePoint Development Tip: Using LINQ to query a SharePoint List

Do you want to use LINQ to query SharePoint information? Read on!

Over the past couple of days I have been playing with an internal project, so I thought I would play and query the lists with LINQ... here is what I came up with!

Because a SPListItemCollection inherits from ICollection, we can attack it with a LINQ query... and that we shall!

A bit of background, I am using a Web Part to render the information to the user. The Web Part has a several properties for the user to supply information to configure it (they will appear in the "Miscellaneous" section of the Web Part Properties Pane). The properties are as follows, the CAML property is optional, but it gives an easy way to filter information from the list without going into the code:

   1: Private _siteurl As String = ""
   2: <WebBrowsable(True), _
   3: WebDisplayName("Web Site URL *"), _
   4: WebDescription("The site the list is located."), _
   5: Personalizable(PersonalizationScope.User)> _
   6: Public Property SiteURL() As String
   7:     Get
   8:         Return Me._siteurl
   9:     End Get
  10:     Set(ByVal value As String)
  11:         Me._siteurl = value
  12:     End Set
  13: End Property
  14:  
  15: Private _listGuid As String = ""
  16: <WebBrowsable(True), _
  17: WebDisplayName("Test Management List GUID *"), _
  18: WebDescription("Enter the GUID for the List."), _
  19: Personalizable(PersonalizationScope.User)> _
  20: Public Property ListGUID() As String
  21:     Get
  22:         Return Me._listGuid
  23:     End Get
  24:     Set(ByVal value As String)
  25:         Me._listGuid = value
  26:     End Set
  27: End Property
  28:  
  29: Private _camlQuery As String = ""
  30: <WebBrowsable(True), _
  31: WebDisplayName("CAML query for the webpart"), _
  32: WebDescription("Enter the CAML for the List."), _
  33: Personalizable(PersonalizationScope.User)> _
  34: Public Property CAML() As String
  35:     Get
  36:         Return Me._camlQuery
  37:     End Get
  38:     Set(ByVal value As String)
  39:         Me._camlQuery = value
  40:     End Set
  41: End Property

The first thing we need to do in the process is attach to the site and then web that we want we want to query. To do this I do the following:

   1: ' Create a Web object to use through the routine
   2: Dim Web as SPWeb
   3: ' Crate a local SPWeb Object
   4: Dim _thisweb As SPWeb
   5: ' Open the site with the URL supplied by the user
   6: Dim SiteColl As SPSite = New SPSite(SiteURL)
   7: _thisweb = SiteColl.OpenWeb
   8: ' Write the SPWeb Object to the property
   9: Web = _thisweb
  10: ' Clean up the SPWeb Object
  11: _thisweb.Dispose()
  12: _thisweb.Close()

This gives us an SPWeb object to play with. In the next snippet of code we attach to the list and create a CAML query object (SPQuery) that we will apply if it was supplied:

   1: ' Attach to the list
   2: Dim thisListGUID As Guid = New Guid(_listGuid)
   3: Dim list As SPList = Web.Lists(thisListGUID)
   4:  
   5: ' Define the Query
   6: Dim query As SPQuery = New SPQuery(list.DefaultView)
   7: If CAML <> "" Then
   8:     query.Query = CAML
   9: End If

Now we have all of that set up, we can make the LINQ query. in this query we are simply retrieving the data, but it is possible to sort, group by etc. as well.

   1: Dim linqQuery = From Z As SPListItem In list.GetItems(query) _
   2:                                   Select Z

Now we have the information, we can loop through it and do what we want with it. Below I have shown we can use a Lambda Query to group SharePoint information. In the example list I have Title, Category and Status fields and I want to group the information by the Category and then do something depending on the status, it may be some conditional formatting depending on other properties or maybe assign a task... anything really.

The reason for the substring is that SharePoint formats fields with an ID and then the Human Readable value, e.g. 1;#Status. We only want what is after the #.

   1: Dim CategoryTitle as String = ""
   2: For Each i In linqQuery.GroupBy(Function(a As SPListItem) a("Category"))
   3:     CategoryTitle = i.Key.ToString.Substring(i.Key.ToString.LastIndexOf("#") + 1)
   4:     For Each item In i
   5:         Select Case item("Status").ToString
   6:             Case "Open"
   7:                 ' Do Something
   8:             Case "Closed"
   9:                 ' Do Something
  10:             Case Else
  11:                 ' Do Something else
  12:         End Select
  13:     Next
  14: Next 

Hopefully that is a fairly quick and easy demo of how to get information from SharePoint as objects and use them!

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SharePoint Tip: Creating Multiple Sub-Sites with STSADM

Using STSADM to create multiple copies of one site!

In this post I will go cover the creation of a site using the STSADM tool. If you want to clone a few sites and re-create several copies of them this is the easiest way to do it. This is really handy if you have a base Project Management or Team Site that you want to use for a few different areas of your business!

STSADM Export - Exporting the base site

The first step of the process is to create a "template" for us to re-use when creating the copies. To do this we use the STSADM -o export command. Below is the syntax to do this. As always, I put this into a batch file so I have to change the directory to the 12 hive so I can run STSADM.

   1: cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin 
   2: REM Export the base site to a folder on the file system
   3: stsadm -o export -url http://yoursite/demosite/ -filename c:\SiteBase\ -includeusersecurity -versions 4 -nofilecompression -quiet 

Creating the Site and Importing the base template

The next part of the process is to create a base site and then import the "template" we exported above.

Note: Make sure you use the same site template for the createweb command as you used to create the base template! not doing so will cause an error and the import process will not work.

Below is the syntax to create the site and import the exported "template".

   1: cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin
   2: REM Create a site base
   3: stsadm -o createweb -url http://yoursite/NewSite -title "Demo Site Name" -sitetemplate STS#0 
   4: REM Import the template we exported 
   5: stsadm -o import -url http://yoursite/NewSite -filename c:\SiteBase\ -includeusersecurity -nofilecompression -quiet 

Now that we have this we can reproduce it to create multiple instances of the same site!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SharePoint Tip: Upgrading a SharePoint (SP0) Content Database to SP1

Moving a SharePoint content database from SP0 to a deployment with SP1

If you have installed SharePoint (SP0) and you want to move a content database to a deployment running SP1 without upgrading the whole farm, read on!

First off, create a blank team site (Central Administration > Application Management > Create or extend Web application) and then follow the steps below.

When you attempt to attach the database through the central admin web interface, you might get hit with the following error:

Attaching this database requires upgrade, which could time out the browser session.  You must use the STSADM command 'addcontentdb' to attach this database.

To get around this, do what the error says...

  1. RDP to your SharePoint server
  2. Open the Command Prompt (Start > Run >CMD)
  3. Paste the following line into the prompt "cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin", this will take you to the 12 Hive
  4. Type the following command:
    stsadm -o addcontentdb -url http://SiteName -databasename WSS_Content_DATABASENAME -databaseserver DOMAIN\DATABASESERVER
  5. Hit enter, and all going to plan you will get: Operation completed successfully

To make sure, go to Central Administration > Application Management > Content Databases and it should be there. Take the origional database (the one created when you created the site) offline and make sure this one is the only one online. Navigate to your site and again, make sure it is all there!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SharePoint Tip: Silent/Unattended Install and Configuration of Office SharePoint Server (MOSS 2007) and Windows SharePoint Server (WSS 3.0)

Look mum, NO HANDS! Unattended installation of SharePoint.

As mentioned in a previous post, we have a few staging environments for SharePoint that come and go with the various projects. To make the process of installing these environments a lot easier (and so I can spend more time cutting code), I wrote a batch file that, well, installs SharePoint and configured it for me!

I did some hunting and found Joel Oleson's Blog about silent installs, added that information with the MSDN article on the config.xml and away I went! But, that was only half of the battle, the next part came curtsy of Keith Richie and his post on Psconfig.exe, explaining how to use the Psconfig.exe command-line tool to perform the configuration of SharePoint. There is also a great amount of information on MSDN about Psconfig. Finally, using some of the STSADM functions the base site was created.

First off, I think some background is needed now about the environment this is all going on. I am using Windows Server 2008 and I have installed IIS already.

Installing SharePoint 

Alright, first part of this process. I have the install binaries in a network shared folder with service pack 1 extracted to the updates folder (see Martin Kearn's blog about how to create a ‘Slipstream’ installation for MOSS with SP1, the same process will work for WSS 3.0 OR you can get all ready done, have a look at this blog on the WSS and MOSS with SP1 release).

Next I created my config.xml following Joel's post. Below is the contents of that file:

   1: <Configuration>
   2:     <Package Id="sts">
   3:         <Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes" /> 
   4:         <Setting Id="REBOOT" Value="ReallySuppress" />
   5:         <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL" /> 
   6:     </Package>
   7:     <Package Id="spswfe">
   8:         <Setting Id="SETUPCALLED" Value="1" /> 
   9:         <Setting Id="REBOOT" Value="ReallySuppress" /> 
  10:         <Setting Id="OFFICESERVERPREMIUM" Value="1" /> 
  11:     </Package>
  12:     <INSTALLLOCATION Value="%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\Data" /> 
  13:     <Logging Type="verbose" Path="%temp%" Template="Office Server Setup(*).log" /> 
  14:     <Display Level="basic" CompletionNotice="no" SuppressModal="No" NoCancel="Yes" AcceptEula="Yes"  /> 
  15:     <PIDKEY Value="xxxxxxxxxxxxxxxxxxxxxxxx" /> 
  16:     <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL" />
  17:     <Setting Id="SERVERROLE" Value="SINGLESERVER" /> 
  18:     <Setting Id="USINGUIINSTALLMODE" Value="1" /> 
  19:     <Setting Id="SETUP_REBOOT" Value="Never" />
  20: </Configuration>

The above config.xml file is called along with setup.exe to install SharePoint without interaction! 

Command that is called:

\\server\Sharepoint\MOSS2007wSP1\x64\setup.exe /config file://server/Sharepoint/MOSS2007wSP1/config.xml

Configuring SharePoint/Creating Site Collection

Next we need to run the Psconfig and STSADM commands. I followed the instructions on Keith's blog and added my own STSADM command to create the default site and came up with this:

cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin
psconfig -cmd configdb -create -database SP_Config -admincontentdatabase SPT_Content -cmd adminvs -provision -port 30000 -windowsauthprovider onlyusentlm -cmd quiet
stsadm -o extendvs -url http://YourSite -ownerlogin Domain\User -owneremail you@yourcompany.com -sitetemplate STS#0 -description "Site Description"

Then, all you need to do is put it all together and pop it in a .bat file, here is what I came up with:

   1: ::Install SharePoint
   2: REM --Connecting to SharePoint Install Files and Starting the SharePoint Install--
   3: \\server\Sharepoint\MOSS2007wSP1\x64\setup.exe /config \\server\Sharepoint\MOSS2007wSP1\config.xml
   4: REM --Configuring SharePoint--
   5: cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin
   6: psconfig -cmd configdb -create -database SP_Config -admincontentdatabase SPT_Content -cmd adminvs -provision -port 30000 -windowsauthprovider onlyusentlm -cmd quiet
   7: REM --Create a site with a default site template--
   8: stsadm -o extendvs -url http://YourSite -ownerlogin Domain\User -owneremail you@yourcompany.com -sitetemplate STS#0 -description "Site Description"

Running the above batch file will install and configure SharePoint, giving you a default instance to start you off with!

Currently rated 4.8 by 4 people

  • Currently 4.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5