Navigation

Tuesday, 19 August 2008

How to access STSADM from any directory

This is a nice quick tip for the August holiday season.
 
Open up the following:
 
Start --> Control Panel --> System
system_dialog
 
 
This should open up the System Properties dialog.
 
Go to the Advanced Tab and click on Environment Variables.
 
environment_var
 
Find the variable called "Path" and append this to the end:
;c:\program files\common files\microsoft shared\web server extensions\12\bin
 
env_var_path
 
That should be it.
 
You may need to re-open ay Command Prompt windows before you can use this.
 
Now you can just call "stsadm.exe" from any command prompt window!
 
Note - If you find type "stsadm.exe" a bit laborius, try adding another one:
Name: STSADM
Value: stsadm.exe
 
env_var_stsadm
 
Hopefully you get how this would work


Monday, 23 June 2008

The Key to successful SharePoint Projects

I got 3 words for you ...

Plan
Plan
then Plan some more ...


Ok .. so this isn't specific for SharePoint, all Software development projects are reliant on planning for successful execution (how can you know if you have delivered, if you don't know exactly what you are supposed to be delivering?) but SharePoint has this point in spades.

The first reason is Scaleability. SharePoint scales extremely well (up to 40TB in Lab Conditions according to the Microsoft SharePoint Team Blog). In fact there is an excellent Whitepaper recently available on this topic: SharePoint Server 2007 Scalability and Performance whitepaper.
However ... this level of Scaleability can only come if it has been planned for. You cannot simply install SharePoint "OotB" (Out of the Box) and expect it all to work.

The main effort required in the Scaleability process is the idea of "Site Collections", each of which is reported to scale easily up to about 50GB (although the labs mentioned above had >100GB Site Collections). Either way, if you are looking at an enterprise level implementation you are probably going to run out of space at some point and that will cause problems.

So .. you need to factor in Site Collections to your infrastructure. I won't spend ages talking about them, but there is a great article by Hiran Salvi on Sites vs Site Collections that is a must read on the topic.

The other main factor is Content & Metadata Maintenance (also sometimes referred to as "Metadata Governance"). If you have been working with SharePoint for a while then you are bound to come across a client who asks the following:
 "Can I add a column to all of my Document Libraries?"

Now ... if you haven't planned for Content Types then this could be a really big headache! Content Types are effectively the schemas that define all of your SharePoint storage. Each time you create a Document Library it is using the OotB "Document" Content Type. Now .. you could go and just modify the Library itself, but then you are effectively breaking your Content Type structure and that is bad mojo! (what happens when you want to modify said column after you've added it to 50 libraries?? you'll need more than one cup of coffee for that job!). The main problem is that you cannot modify the "Document" content type either! (well .. you could ... but you will probably break something doing it!). The reason is that a lot of other places in SharePoint also use that Content Type (such as "Master Page Gallery" and "Page Libraries" to name but a few!). A second major problem is that you cannot easily modify all of the Document Libraries either! (I mean .. thats what Content Types are for .. right?)

The recommended practice is to create a custom Content Type for all of the user-created Document Libraries. If the client wants to add a column .. no problem, you just add the column to the new "custom" content type, and Robert's your father's brother!

Of course .. if you didn't plan for that in the beginning ... well .. you'll be in for some pain! You either have to pay a temp to sit on your server for days on end re-allocating all of the Content Types system wide, and then you still haven't solved the problem of new lists and libraries that keep getting created! Or you have to get a developer to spend some very expensive days writing code to go around and do it all automatically!

.. either way .. best to be avoided and will be far cheaper in the long run if you plan for it!

The final point on planning (and by no means the final word on the topic, just the final point in my ramblings) is the following:
Who is going to use the system? And how will they use it?

Far too many people assume that SharePoint, being a Microsoft product .. hmph .. will just work out of the box and will solve all their problems (including World Peace). The truth is .. SharePoint is an advanced and very very complex web development platform.
Yes, it provides a whole raft of management, maintenance and administration functions and offer variability and flexibility like few other web based systems before it! But it requires time, a LOT of thought and plenty of expertise to deploy correctly.
The most important part of this is the users. What business requirement is being satisfied? What is the reason for using SharePoint (or any web based system?), what are the problems and how has this implementation been designed to solve those problems?

Last but not least .. never never never neglect the end users, especially the Content Managers. I have seen 2 things commonly happen which cause projects to fail:
1) "We'll just give them all Team Sites"...
This is a classic. You create 500 Team Sites ... one for each department / user group / business stream / office / project.
There is one major problem. they are ALL EMPTY!
99% of users will load up their nice bright shiny portal ... and look at these nice big expensive blank pages. Then log off and probably never return.
If you don't give them content and relevant design then you won't get any buy in!

2) "We'll let the Site Owners do what they want ..."
This is probably worse that point (1). At least there you can rebuild and you don't have to worry about the current system (because it's pretty much empty .. right?).
Now don't get me wrong ... this technically CAN work .. but you need Effective Training to make sure that your Site Owners understand the followig ideas:
* How to manage content
* How to create a hierarchical structure that works
* How to manage security permissions
* What is vision for the system as a whole?
* What do we want people to use the system for?

Without a unified vision for the system you end up with an implementation that is haphazardly put together, where each site has it's own layout, classifications and web parts. Trying to central manage a system like that will be a nightmare .. for both the project leaders and the systems administrators!

Well .. thats my ramblings for now, hope some of these nuggets have sunk in.

As always ... comments welcome!

- Martin Hatch

Friday, 9 May 2008

Talking about Microsoft Certified Professional Developer- Web Developer

Yay me... on Wednesday 7th May 2008 I passed the Microsoft Certified Professional Developer - Web Developer exam. Probably one of the hardest exams I've sat so far due to it being more conceptual (does this specification meet the requirements? … ) rather than technical (which class / method should you use for ..) kind of questions.

According to Microsoft I'm one of the first 5000 people worldwide to pass this one Open-mouthed

Hurrah ... now what's next ??



Wednesday, 16 April 2008

Displaying an Access Report in a Web Part

ok .. so who uses Microsoft Access anymore ???
 
You might be surprised that the Report Designer is becoming increasingly popular now that the ability to link to SharePoint data has been added in. From any SharePoint list you should be able to select "Actions" and then "Open in Access" .. which then gives you the option of taking a copy of the data, or (even better) creating a link to the data in SharePoint (allowing you to report and query the SharePoint data direct from the SharePoint database!!)
 
This of course opens up the possibilities of non-technical end users creating rich reports using nothing more than Microsoft Access and a couple of out of the box web parts.
 
 
I must give a nod of thanks to the guys over at ProgrammingMSAccess, their samples on embedded Snapshots are the ones I am using in my web part.
So .. how can we get up and running?
 
First, add a Content Editor Web Part. Enter the following code into the Source of the web part (by modifying the web part, and using the built-in source editor).
<OBJECT ID="SnapshotViewer" WIDTH=800 HEIGHT=600
CLASSID=
"CLSID:F0E42D60-368C-11D0-AD81-00A0C90DC8D9">
<PARAM NAME="_ExtentX" VALUE="16722">
<PARAM NAME="_ExtentY" VALUE="11774">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="SnapshotPath"
VALUE=
"http://webserverURL/folder/snapshotfilename.snp">
<PARAM NAME="Zoom" VALUE="0">
<PARAM NAME="AllowContextMenu" VALUE="-1">
<PARAM NAME="ShowNavigationButtons" VALUE="-1">
</OBJECT>

The only part you have to change is the "VALUE" attribute for the "SnapShotPath" node (I've highlighted it for you to make it easy ;)). This needs to be a URL that points to the SnapShot file (preferably in a Document Library in your SharePoint Site - Anyone viewing this report will need Read access to it.).

That is pretty much all there is to it. Feel free to play about with the "Width" "Height" "AllowContextMenu" and "ShowNavigationButtons" ... I'm sure they are all pretty straightforward! ;)

One final note - All users who want to view the report must have Snapshot Viewer for Microsoft Access installed on their workstation (otherwise the web part will just be blank).

Example Report - Shown on a standard Web Part Page:

 Snapshot Image



SQL Server Feature Comparison (2005 – 2008)

This is something we've had under our hat where I work for a while.. as you should be aware if you do a "stand-alone" install of WSS 3.0 (or MOSS 2007) then it installs "SQL Express Edition" (a.k.a. MSDE) .. but this version does have some startling limitations!
 

SQL 2005 Feature Comparison

 

Express

Workgroup

Standard

Enterprise

Number of CPUs

1

2

4

No Limit

Max. RAM

1 GB

3GB

OS Limit

OS Limit

64-bit support?

 

 

X

X

Max. Database Size

4GB

No Limit

No Limit

No Limit

Clustering / Mirroring

 

 

X

X

Online Restore / Recovery

 

 

 

X

Management Studio

 

X

X

X

Job Scheduling (through Agent)

 

X

X

X

Import / Export

 

X

X

X

Web Services

 

 

X

X

 

Much more also available at Microsoft SQL Server 2005 Features Comparison.

 

SQL 2008 Feature Comparison

 

Compact

Express

Standard

Enterprise

Number of CPUs

1

1 (per server)

4

No Limit

Max. RAM

OS Limit

1GB

OS Limit

OS Limit

64-bit support?

 

 

X

X

Max. Database Size

4GB

4GB

No Limit

No Limit

Clustering / Mirroring

 

 

X

X

Online Restore / Recovery

 

 

 

X

Management Studio

 

(tool)

X

X

Job Scheduling (through Agent)

 

 

X

X

Import / Export

(tool)

 

X

X

Web Services

 

 

X

X

 

Detailed comparisons can be found between Compact and Express … and Standard and Enterprise



Thursday, 3 April 2008

Some things to note about using "Templates"

I’ve been doing some testing, mainly prompted when I was questioned about Site Templates (I originally thought that Workflows built in SharePoint Designer would not be copied over in templates) and they proved me wrong! I have done some reasonably extensive testing, and have come to the following results:

Quick Summary

  • SharePoint Designer Workflows will ONLY be copied over in a SITE TEMPLATE WITH CONTENT (any other configuration fails)
  • Custom Workflows (including the “out of the box” ones) will be copied over in ALL TEMPLATES.
  • If you hide the “default” content type then it will re-appear after using a Template.
  • Version history is not preserved when using templates with content.

List Templates include the following items:

  • Custom Workflows
  • Adding more Content Types
  • Re-ordering the Content Types
  • Changing the default Content Types
  • Adding a custom Content Type
  • Versioning Settings
  • Content approval Settings

Site Templates include all of the above, but if you also select “Include Content” then you will also get “SharePoint Designer Workflows”!

If is important to note that if you hide one of the “out of the box” content types from your list then saving a List Template OR Site Template will not have any effect! The content type will be back and visible when your new list / site is provisioned!

I then did some more general “what if” scenarios:

 

Query

Answer

What happens if the custom Content Type in the Site Template does not exist in the target system?

It creates a LOCAL (i.e. list level) copy of the Content Type, and links it to the parent of the original content type.

This means that it works as it used to work, but the “central” copy of the content type no longer exists so maintenance has to be done manually and changes cannot be “pushed down”.

What happens if you delete a Custom Content type while it is in use normally?

Error – “The Content Type is in use”

If you save with content, does it preserve version history?

No.

All items copied over will be created as version 1.0.

All draft versions are removed.

 

It is also important to state the Disadvantages of using Templates and that is mainly regarding Site Templates, and it is 3 main things:

  • Performance. Using lots of site templates will degrade the performance of your system.
  • Maintability. Maintaining the structure going forward will be difficult, as you have no “schema” to modify. All you can do is
  • Limited to the User Interface. Mainly with reference to lists, changing the default fields, default content types, and modifying some of the “back end” properties is not possible through the user interface, and therefore cannot be achieved using “List Templates”.
  • Automation. There is still much more flexibility in terms of automation when using “definitions”. We can tie in event handlers and automation tools to do “almost anything”.


Tuesday, 4 March 2008

Correctly disposing SPWeb objects

I guess SharePoint development is a bit like riding a wave. First off you find you do almost everything wrong ... after a while you pick up some of the "best practices" (like disposing SPWeb objects) and then you find that you are still doing things wrong. Well ... thats the learning curve I'm afraid .. and it rounds down to where your SPWeb object came from, and when you should be disposing it.
There are several different ways of retrieving an SPWeb object.
Take the following 3 examples:
1) SPContext
SPWeb web = SPContext.Current.Web
2) OpenWeb
SPSite site = new Site("http://myserver/");
SPWeb web = site.OpenWeb("");
3) Site "RootWeb"
SPSite site = new Site("http://myserver/");
SPWeb web = site.RootWeb;
All 3 of them are valid SPWeb objects, but they are also all slightly different.
Lets start off with SPContext. This is basically a context object which represents the context of the current site that you are navigating. The SPContext.Current reflects where you currently are in the SharePoint site collection (so SPContext.Current.Web will return the SPWeb object that represents the site from which your code is executing ... for example .. the site that your web part is sat in).
There are 2 major issues with using SPContext.
1) It is context sensitive. Yes .. I know thats like saying the sky is blue, but you do need to consider this if you are looking at generic code that might be accessed from multiple projects. Pulling out the "SPContext" properties is fine from a web part, but you don't want the same code executing from a Console Application or a Workflow Custom Action.
2) SPContext is in use by all manor of controls and parts on the site and the page. If you dispose of the SPContext.Current.Web object then you will find that you get a nasty error message next time you try to access that object (forcing you to refresh the page). So if you've ever seen the error message below, check your disposal!
"Trying to use an SPWeb object that has been closed or disposed and is no longer valid"
Make sure you dispose of OpenWeb("") objects!
This is very important. When you are basically just creating your own SPWeb objects you will need to make sure that you dispose of your objects correctly. The best way of doing this is encompassing your web object in a "Using" statement
using(SPSite site = new Site(http://myserver/);
{
using(SPWeb web = site.OpenWeb(""))
{
// work with web object
} // web object disposed
} // site object disposed
Do NOT Dispose SPContext.Current.Web or SPSite.RootWeb
If you write a using statement such as:
// This is bad! m'kay ?
using(SPWeb web = SPContext.Current.Web)
{
}
What you are actually doing is disposing the SPContext.Current.Web object .. not just your own "web" object. THIS IS BAD. You should actually just declare them with a single, normal line, such as:
SPWeb web = SPContext.Current.Web;
And exactly the same applies to SPSite.RootWeb properties too!


Thursday, 28 February 2008

SUGUK - London Meeting

If you don't know about them already there is a group that call themselves the "SharePoint User Group UK" (SUGUK). They meet every now and again, and quite often you'll get people from Microsoft (or MVP's) giving presentations on topics relating to SharePoint (usually either development or infrastructure).

Well, there was one such meeting last night, covering topics such as Kerberos in SharePoint (why, when and more importantly .. how?) and another topic (very close to my heart) about how to maintain multiple SharePoint environments throughout a project lifecycle (e.g. Dev | Test | Stage | Prod).

They are free to attend, and usually there is a good chin-wag down the pub afterwards so plenty of opportunities for networking or just getting those crucial last few bits of info on a topic.

The SUGUK Website contains more information, including an "upcoming meetings" forum where you can keep track of when and where the next events are going to be. There's also a development forum of pretty well informed people, which might be a bit easier than the heavily oversubscribed MSDN Forums.

Definately worth a look!


Tuesday, 19 February 2008

Tip - Apply Branding in WSS 3.0

Here's a quick tip, cos I don't have loads of time.
We've had lots of enquiries from our clients about Branding in WSS 3.0. If you are running MOSS 2007 then you have all of the nice "Look and Feel" settings when you go to Site Settings, allowing you to not only change the Master Page and Style Sheet, but also to push those changes down through the rest of the Portal.
Well ... to put it bluntly, WSS 3.0 won't let you do any of that.

So .. how about creating a Branding Feature?
You can write custom event handlers for Features (called Feature Receivers, using the SPFeatureReceiver class), so that you can have code that executes when a Feature is Installed, Activated, DeActivated or Uninstalled.
I won't go into the details here, but there are some great articles about this on the web and MSDN.

So hows this for an idea?
Write yourself a Feature that applies Branding to WSS 3.0 sites (or any site for that matter!). You can make it set a new Master Page, change the Style Sheet, the Logo, set a custom "Site Theme" or even just inherit all those properties from the Parent site.

One great use (that we use quite regularly) is to create a Hidden Feature that just applies the Parent Site's branding settings to the new site. You can then use Feature Stapling to make sure that ANY (staple to "GLOBAL") site that gets created will be branded .. you don't need to worry about the site definition!

As for the values used for the Branding, well you can pass these in as "Properties". Every feature can have them, and they are specified as follows (in the Feature.xml file).
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
...>
    <Properties>
      <Property Key="NewMasterPage" Value="/_layouts/CustomBranding/NewMasterPage.master"/>
    </Properties> 
</Feature>
So in that feature we have specified a Property called "NewMasterPage" (you can have as many of these as you like).
Then ... to get that Property value out in your Feature Receiver you can use the following line of code:

string strMasterUrl = ((SPFeatureProperty)properties.Feature.Properties["NewMasterPage"]).Value;
If the property doesn't exist, or the value is blank then it will return an empty String (so you shouldn't need to worry about null reference exceptions!)

Then, all you need to do is change the SPWeb property and call SPWeb.Update() to apply the changes! For example:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
// apply branding
using (SPWeb web = (SPWeb)properties.Feature.Parent)
{
   web.MasterUrl = strMasterUrl;
   web.Update();
  
}

}

Hope this gives you some good starting points! You might want to extend this further; here are some interesting things you might do:


  • Add a Property Flag to reset all sub-site branding settings. This can then be activated at the top level to reset all branding Site Collection wide.


  • Add an "inherit from Parent" Property. Then you can use SPWeb.ParentWeb to get the parent SPWeb object (and all of it's branding settings).


  • Store the "original" branding settings (before you overwrite them) in the SPWeb.Properties hashtable. Then, add an "DeActivating" event, and put all the original properties back again! (so when you deactivate the feature, it puts the branding back in place.. a great "rollback" option!)


Good luck .. and get Branding!!!

MKeeper


Thursday, 7 February 2008

when I met Bill Gates ...

Well ok ... so I didn't actually get to meet him .. but I did see him talk, and mighty exciting it was too (unless you are one of those anti-software / anti-capitalist / anti-success people who don't like him).

I had the fantastic opportunity of going to the Microsoft Windows Server & Tools Pre-Launch Event in London (Park Lane Hilton), which was only available to Microsoft Gold Partners (so a thumbs up there to my employers!) and very swanky and posh (but a thumbs down to the caterers ... who on earth serves steak and chicken from a buffet but doesn't provide any tables or chairs ??? ever tried to use a knife & fork while holding your own plate ??).

Well, Bill Gates, the big man himself, was giving one of they key-note speechs about "The Miracle of Software". Basically talking about how software has evolved to enrich people's lives and what software design should be about (i.e. empowering people). It was all quite nice and they had a Q&A session afterwards (although quite blatantly pre-planned questions).

Some of the other speakers had some interesting things to say, mostly the buzz-words were "Hardware Optimisation" and "Virtualisation" around the Windows Server 2008 "Hyper-V" technology ...  which has led us here to a bit of a conundrum ...

You see ... it is a little known fact that the next version of SharePoint (a.k.a. Office 14) will only run on 64-bit!!!
Now ... this isn't such a problem for the production environments, I can't even think of a non-64-bit CPU that is still being bought for production hardware these days ... but when you go into the development lifecycle things get a bit more tricky!

You see ... at the moment (and I hope this changes) you cannot run 64-bit Virtual Machines on any Virtual Server environment (not even if your host OS is 64-bit). The only piece of technology making this possible is the new "Hyper-V" which is part of the Windows Server 2008 kernel. This is also ONLY possible if you are running a CPU that is BOTH 64-bit and has "Hardware Assisted Virtualisation" (HAV).

That all sounded fine and dandy .. but then I got back to the office and looked at the hefty workstation on my desk ... no HAV and definately no Hyper-V either.

So now we have a bit of a conundrum ... do I upgrade to a HAV compatible CPU? (i.e. one of the new "Quad Core" Intel Xeon processors) so that I can potentially run 64-bit virtual machines (and hence develop new SharePoint environments)?
BUT ... if Windows Server 2008 remains the ONLY platform for 64-bit virtualisation that means I will need a Server 2008 OS to do all my development in (not really suitable for a workstation).

Well .. I've spoken to my Infrastructure Manager and come to a plan. All the dev.team are getting brand new Quad-Core Xeon with 4GB RAM workstations.
IF Microsoft don't release a "workstation" virtualisation platform that can run 64-bit VMs then we are going to convert them all into Servers and buy crappy "terminal" workstations .. and every developer can have their own personal "server" to work in.
IF Microsoft DO release said software ... then hurray ! for we'll have the hardware capable of supporting it.

hmmm .. I wonder if I can convince them to get me 30" widescreen monitors too ???? .....