Tuesday, October 30, 2012

Handling A Risk Rating Matrix In SharePoint Lists

I had to implement a Risk Rating matrix in a SharePoint custom list being used as a Risk Register. The matrix was somewhat askew as shown below:

Likeli-
hood
Certain Low Medium High Extreme Extreme
Likely Low Medium Medium High Extreme
Possible Low Low Medium High High
Unlikely Low Low Low Medium High
Rare Low Low Low Medium Medium
      Insignificant Minor Moderate Major Severe
Rating    Consequence

In SharePoint 2007 this was a challenge but in SharePoint 2010 there was a significantly easier albeit not entirely straight forward way to do this.

The trick here is the askew nature of the matrix and the larger number of combinations. If it was more symetrical then a trivial mathematical formula could have handled this. If there were fewer ratings of likelhood and consequence then a simple logical expression could have done.

SharePoint 2010 Example

So in SharePoint 2010 I created a custom list called Risk Rating that had:
  • A choice column called [Likelhood] with the 5 choices "Certain" to "Rare"
  • A choice column called [Consequence] with the 5 choices of "Severe" to "Insignificant"
  • A calculated column called [Likelihood - Consequence] with a formula = [Likelihood] & " - " & [Consequence]
  • A choice column called [Risk Rating] with the 4 choices "Extereme" to "Low"
  • A calculated column called [Rating] with the formula = [Risk Rating]
  • The [Title] column is changed to optional and hidden 
I then add items to Risk Rating to cover the 25 possible combinations of Likelihood and Consequence.

Now in my Risks list, I add a column called [Initial Likelihood - Consequence] which is a lookup column that "links" to the [Likelihood - Consequence] column of the Risk Rating list, and I pull the [Rating] column across as an additional column.

This is an approach that you can use to "link" SharePoint 2010 lists via a composite key. It is not as pretty as I would like but it works.

Note that the resulting columns are called:
  • [Initial Likelihood - Consequence]
  • [Initial Likelihood - Consequence:Rating]
I used this name to make the example clearer, but a column name called "Initial Profile" would result in more readable linked column names.

You can also use this appraoch to have multiple ratings for each risk. For example you may also have a mitigated, reviewed or current risk rating. This simply means having a different column that has the same lookup properties as the first.

Note that the choice columns in the Risk Rating list can not be linked to with a lookup column, nor brought over as additional columns, even though the hidden Title column can be. This is why I had an additional calculated column for Rating, though instead of the convenience of a drop down, I could have just had a single text column for Rating that would have done the trick.

SharePoint 2007 Example

For those of you still on 2007, this approach could be used.

First I added two hidden calculated columns to the Risks list:

Likelihood Rating:
=IF(ISBLANK([Likelihood]),-1,CHOOSE(((FIND([Likelihood],"Rare....,Unlikely,Possible,Likely..,Certain.")-1)/8)+1,3,4,5,7,11))

Consequence Rating:
=IF(ISBLANK([Consequence]),-1,CHOOSE(((FIND([Consequence],"Insignificant,Minor........,Moderate.....,Major........,Severe.......")-1)/13)+1,0,3,4,8,11))

And then I added the final resulting risk as another calculated column:

Risk Rating:
=IF(OR([Likelihood Rating]=-1,[Consequence Rating]=-1),"",CHOOSE(MIN(4,(([Likelihood Rating]*[Consequence Rating])/19)+1),"Low","Medium","High","Extreme"))

Again, not pretty but it works. The real challenge was coming up with the weightings and divisor.

This approach should work equally well in 2010, but the previous option provides easier control.




Tuesday, October 23, 2012

SharePoint PowerShell Regional Settings Gotcha

I was trying to work out how to change the regional settings for a site using PowerShell and got the following working:

$web = Get-SPWeb http://foo
$web.Locale = 3081
$web.RegionalSettings.TimeZone.ID = 76
$web.Update()
$web.Dispose()

However when I put the setting values into our XML config file I got the following error on the setting of the Locale.

Exception setting "Locale": "Cannot convert value "3081" to type "System.Global
ization.CultureInfo". Error: "Culture name '3081' is not supported.
Parameter name: name""
At line:2 char:6
+ $web. <<<< Locale = "3081"
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The problem is that anything read from the XML file was coming across as a string.

The Locale property is of type CultureInfo which has an overloaded constructor that takes either an integer or a string. PowerShell attempts to coerce the type using best fit and so uses the constructor that takes a string. So to fix this I either needed to first coerce the string value to integer using something like:

$web.Locale = 0 + $locale

or used the Culture Name rather than the identifier, so the equivalent of:

$web.Locale = "en-au"

I changed the 3081 to "en-au" as I thought that was more informative.

The interesting thing is though that the TimeZone.ID property is a unsigned 16 bit integer so powershell had no problem converting and it works fine.

Incidently the default time zone for 3081 appears to be Hobart (42) while I'm setting this to Sydney, Melbourne, Canberra (76). Considering the collective portions of Australia that both time zones represent I was a little suprised by this choice. I suspect it takes the first matching timezone in order of ID.

Wednesday, October 17, 2012

Why I Hate SharePoint #3

There are a lot of people out there that love SharePoint. I know they exist because I've met a couple, and coward as I am, kept my mouth shut. To be honest, if you use SharePoint exactly as it was intended, it is probably OK.
Maybe I'm trying to do something really exceptional here but it doesn't feel that way. So to continue the theme, here are a few more "exceptional" things.


#1. I've added a Wiki library to a site and to the wiki home page I add a list web part of the wiki pages, using the default view "All Pages". I then generaet a site template, create a new site from this template, but then any attempt to access the wiki home page or the wiki (since the default action for the wiki is to show the home page) falls over with a correlation ID error, in this case an InvalidOperationException at SPListItem.get_EffectiveBasePermissions().

But if I go back to the original site, create a custom view explicitly based on the "All Pages" view, change the web part on the home page to use that view, and then generate the site template again, then now I can create sites that don't have this issue.


#2. Take the SPGroupCollection.Add( name, owner, defaultUser, description) method which allows you to create a SharePoint group and add it to a site. What sort of error do you expect to get if say the specified owner does not exist. Something like "owner is unrecognised". Well what I got was an error that basically said something like "one of the parameters was not in the accepted range". Most of the .Net framework actually provides really good exception messages. To me such a generic message is usually indicative of either rushed code or lack of caring. It certainly isn't helpful to someone who is trying to work out why a piece of PowerShell has suddenly stopped working.


Incidently PowerShell has been one of the positives from the SharePoint project I'm on. While it seems to have an almost accidental syntax to it, there are also a lot of interesting features. I'll save my views on PowerShell though for a different post.





Thursday, October 11, 2012

Why I Hate SharePoint #2

Ok. Some content. I've just picked a few of the issues that I've encountered in the last couple of projects.

Now to be fair, SharePoint is a large complicated piece of software with some serious legacy issues. Producing a bug free piece of software is non-trivial and some would argue not even possible.

However, given the resources for development and testing, and the push SharePoint has from MS as a flagship product, they really should be able to do better than this.

1. If you create a Picture Library called "Images" (some might consider this an obscure name for a picture libary) then you then can't turn publishing on.

2. Say you have a site template that you want to generate a new site template from. So you install the original site template .WSP, you generate a new site from the template, and then you make all the modifications you need. But you don't want to have to include the old site template as well, so you remove it. Your modified site works fine and there is no issue... untill you go to generate the new site template, which will now fall over in error. And there is no way to rectify this. Once the original solution is deactivated, you don't even have to remove, you can never generate a site template again.

Actually the SP Solution Exporter class and its dependancies seem to be one of the weakest pieces of code I've encountered for a long time. It falls over from so many different things. Here is another example.

3. I have a sub site that wants to have a list web part where the list is in the parent site. There is a solution where you create a similar web part in the parent site, then export it as a web part definition, then import it into the sub site and then create a new web part from it in the subsite. Everything works fine... until you go to generate a new site template, which again falls over in error.

4. Compare the user experience with a simple choice control to the SP 2010 metadata control. The later aint pretty. Sure it's got to do a lot more but the user shouldn't have to suffer for that. It screams for an improved UI and probably some server side caching and prefill.

5. If you add a metadata column to the blog comment list the user gets a correlation ID error page every time they add a comment (though the comment does get added). The reason is because the blog team thought that the best way to clear controls was to set the Value property to null, while the metadata team thought that nobody would ever set the Value property to null (though the error you get says something like you have passed a multi-value metadata value to a single value metadata field or vice versa depending on whether the metadata field has the multi-value box checked or not.

6. You can't generate a site template from a site that has had publishing turned on. Actually you can but the link to do so has just been removed. If you turn publishing back off, then the link reappears, but if you look it up on the Internet, Microsoft say your solution is now unsupported. From reading on the Internet, it appears this bug was first discovered during early testing of SharePoint 2007, but has since been redefined as a feature so will now never be fixed as evident in SP 2010. (How the hell does anyone call this a feature) And why isn't there a wanring when you generate the site template that it won't be supported? What if you weren't the person who turned publishing on and back off?

7. What does the SP team think that you will only ever want to change the master page if you have turned publishing on?

8. Why does Quick Luanch and Top Nav have to be moved and renamed when publishing is turned on, now in the Navigation link called Current and Global nav?

9. Why did we get all those arguments in SP 2007 about calculated fields can only be recalculated when the specific row or the list definition is editted BECAUSE of  security and performance, only to have these sames reasons thrown out the window in SP 2010. This of course is an improvment in SP 2010, but it certainly makes you wonder about the real reasons.

10. And why we are on the subject of calcualted fields in SP 2007, what is the point of all those statistical functions being supported. It's not like you can aggreagate across all items in a list, and some of them are so obscure that you have to wonder about their inclusion, especially when more valuable functions were left out, like looking up a value on a different list.


Why I Hate SharePoint #1

I've been "working" with SharePoint lately and being constantly reminded why I hate this product. This post is pure therapy, an attempt at comedy and absolutely no content, but subsequent posts will look into some of the issues I've encountered in a little more detail.

My favourite SharePoint quote is with out a doubt:

"Working with SharePoint is like having a session with a BDSM mistress and forgetting your safety word."

Here are some of my own:

"SharePoint is an environment where you can achieve something new but not feel any smarter from doing so"

"Getting your nails pulled would be less painful than working with SharePoint because eventually you're gonna run out of nails"

"Working with SharePoint is like being dazzled by headlights while crossing the road at night dressed in a rabbit suit"

"...and if you chew off your other arm as well then nobody can make you work on any more SharePoint"

"SharePoint. Recommended by all good masochists"

"What... more SharePoint... aaaaaaarrrrrrggggggggggghhhhhhhhh!!!!!!!!!!"