Wednesday 9 March 2011

Problem with DIP using Lookup Columns

Problem: The Document Information Panel (DIP) in MS Office Word 2010 won’t do lookups to a list within MOSS.  This is a known bug. 
What is affected:  I have tested this on SP2010 and the issue has been resolved.  This only affects MOSS when using the Document Information Panel (DIP) for Word 2010, Word 2007 and Word 2003.

Initial Hypothesis: The issue is caused by MOSS User Interface (UI) when the lookup column is created. The UI links the document library content type to a custom SharePoint 2007 list using a GUID. The issue is that the GUID should be surrounded by {}. SharePoint UI knows how to handle these missing curly brackets however, all the MS Office applications (Word 2010 in our case) need the correct hook-up.  The hook up is wrong, hookup the document libary using a differnt approach.

Resolution:  Login to a WFE that has SharePoint Manager 2007 (codeplex project) installed. Navigate to the SavillsSolar Site Collection and amend the lookup property by surrounding the GUID with curly brackets. The url below details the change and additional information. 
Alternative Resolution: Create the custom list in the root of the site collection, the custom content type for the document library should have a lookup added.  This fixes the problem but requires content type to be create 1st.  Lookup list site column to be created 2nd.  3rd use the custom document contnet type in the library.  Lastly, the custom list has to be in the base/root of the site collection.
Alternative Resolution: Move to SP2010 not to practical but another reason to promote the move to your business.
Summary:  This is a rehash of Bernado Nguyen-Hoan's Blog post on the same topic that allowed me to quickly fix the issue on an old MOSS farm.  The new bit is that the lookup columns from SP2010 using the DIP have been fixed and the best appoach is to have your custom list (lookup list) directly under the site collection.

Source:
http://bernado-nguyen-hoan.blogspot.com/2010/01/problem-with-document-information-panel.html

Sunday 6 March 2011

Unit Testing for SharePoint - Part 1

Overview:  I am not an expert in Test Driven Development (TDD) but the SharePoint Retreat in London has made me think about using this approach for SharePoint 2010 development.  There are various tools to help you perform TDD however, these 2 posts show the approach I am most comfortable with thanks to Andrew Woodward. 

This whole article is based on Andrew's session and I really would recommend to any serious development team to get Andrew in to do some upfront consulting and potentially training.  Upfront costs and his experience would definately be quickly recovered.  If you have already decided to use a TDD get Andrew in to get you dev team up to a good standard with TDD for SharePoint, anyway enough of my sycophantic
dialogue.

Tools:
  • Visual Studio (VS) 2010 any edition;
  • NUnit - preferable to MSTest for SharePoint dev
  • TestDriven.Net (optional)
  • ReSharper (optional)
Objectives:
Part 1 focuses on using setting up a basic "Magic 8 Ball" to unit test the business logic using nUnit. 

Tip: using coding Katas (really good approach to training, this is the 1st time I've used them and they actually really work) to get a full unit testing system working. 
Tip: Write the unit test and then write the code to fix the test.

At the SharePoint retreat, each session started with a:
  1. Review of the last sessions code (if appicable),
  2. Followed by an overview of what will be the next bit of coding logic (instructor lead teaching/demo exercise),
  3. Break into a new pair programming team to code (old code is throw away and a fresh set of code is started that includes all the exercise from all the previous sessions), and
  4. Loop - Back to step 1 (Review each pairs code).
In this post I am describing the 1st session, what you are trying to do is setup unit testing and write a couple of tests for you "Magic 8 Ball". 

Setup
1. Open VS2010, create a new solution file (MagicPost1.Sln).
2. Create 2 new C# class projects, the 1st project contains the business logic code (BOL project) and the 2nd project contains the unit tests (BOLTest project).
3. Change the default class on the BOL project to Ball and the default class on the BOLTest project to BallTest.
4. Add 3 references to the BolTest project. 
All 4 steps are shown below:

dll reference locations:
\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\lib\nunit.core.dll
\Program Files (x86)\NUnit 2.5.9\bin\net-2.0\framework\nunit.framework.dll

5.  Add the basic testing structure to you BallTest.cs code as shown below:
6. Add this basic code snippet to your Visual Studio code snippets (Resharper has better code snippet support).  7. Write you 1st unit test (the simpler the better) as show below:
8. Build your project to ensure it compiles. 9. Comptete the test code as shown below and run the test.
Tip: Strictly following TDD principals your test should fail and then you write code to fix it in the BOL code.

More Info:
Andrew Woodward's codeplex project on the magic 8 Ball which provides the code you can use to build the magic 8 Ball with TDD.
Here is a slide deck to a presentation on the Magic 8 Ball TDD project.

Next Post:
Part 2 of the series looks at testing SharePoint using Type Moch Isolator.

Saturday 5 March 2011

SharePoint Retreat Saturday

SharePoint Retreat London 2011, Saturday, March 05, 2011 London held by Andrew Woodward (@) & Wes Hackett.  A brilliant day, if you get a chance to go to 1 of these you should.  Met some good SP people and got great tips & pointers.  The bonus was I won a Type Mock Isolator licence.

Andrew gave a clear example that we worked on throughout the day, enjoyed the unit testing with nUnit.  I'm not totally sold on the TypeMoch as I feel like I'm testing the SharePoint API but it does increase code coverage.    
More Info:
http://spretreatlondon11.eventbrite.com/
Paul Hunt (@cimares) has done 3 great posts on the SPRetreat event.  Paul has transcribed the sessions extremely well and with good examples delivered in a step by step approach.
Update 10/08/2011: Unit testing Guidance

Friday 4 March 2011

Reset your AD Pswd history

Problem:  As a developer I setup a development machine on my own network and the default security policy forces me to change my password every 60 days.

Hypothesis:  Use Powershell to change how often the password needs to be reset in AD.  I don't know this so if anyone has this script please post it.

Resolution: Use the PS to remove you history.  This at lease allows me to reuse pswds repeatedly so I don't ned up with a lot of versions.  I have multiple VM so it's pretty useful to know my passwords are consistant.  Thanks to Brad Turner for posting this script.

# Pass the number of days to retain on the cmdline
param ([string]$NumDaysToKeepPwdHistory = 14)
# Calculate the date to clear password history against
[string]$ClearPwdHistoryDate= [DateTime]::Now.AddDays(-$NumDaysToKeepPwdHistory).ToUniversalTime()
# Get the WMI Object for your sever (use your server name)
$myserver = @(get-wmiobject-class "Win2008R2-machine6" -namespace "root\MicrosoftIdentityIntegrationServer" -computer ".")
# Clear the Password History
Write-Host "Clearing the Password History prior to (UTC)" $ClearPwdHistoryDate
Write-Host "Result: " $myserver[0].ClearPasswordHistory($ClearPwdHistoryDate).ReturnValue
# New line
trap{
Write-Host "'nError: $($_.Exception.Message)'n" -foregroundcolorwhite -backgroundcolordarkred
Exit
}

Tip:  This should not be done in production, only use on development environements.

Read More:
Brad Turner on removing Pswd history

Update: 2 April 2011 - Edit password setting using Group Policy 

Thursday 3 March 2011

Google's Cloud Connect for Microsoft Office

Google’s Cloud Connect for Microsoft Office has been released and looks like a great option for informal collaboration.  It is not comparable to SharePoint but offers a good option for sharing and managing individual documents.
Problem: A user has a single document that needs to shared with multiple contributors and read-only users.  Document history is required.  User need the ability to go offline and sync up with the document when the have Internet access.
Hypothesis:  There are several options for tackling this problem and in SharePoint world, you can use Groove (Workspace in SP2010) to get a good solution but you will need licences, setup servers or buy BPOS and potentially install Groove/Workspace on users machines.  All the SharePoint solutions are great but they have costs and time requirements and are generally suited to people within the same enterprise or a agreed integration effort for authenticating.

Redefined Problem: The users are an informal group that need to collaborate on MS Office documents, they have no or low budget and they need a version history.  Users come from multiple locations and have Internet access.
Hypothesis:  Google has released a software plug-in for MS Office 2003, 2007 and 2010 that hooks office documents to Google Docs.  Google docs already exists and offers this functionality but not directly from word, also you can't collaborate on the same document at the same time.  So this plug-in is a cheap alternative to a SharePoint Document library with a Grove/Workspace client.  Functionality is very limited but for simple sharing and collaboration, this is a good option.
Resolution:  As always the answer is .. "It depends".  It isn't a competitor but it offers a simple alternative to sharing documents.  A good example would be if I had a document that I need to give to a digital agency using the Google Cloud Connect for MS Office I don't need to get them access to SharePoint.  If it far more informal and won't work for large amounts of data but there are definitely good reasons to use the solution.
Quote:  Shan Sinha Google product manager explains Google's Cloud Connect plug-in “The plugin syncs your work through Google’s cloud, so everyone can contribute to the same version of a file at the same time. You can edit a Word document’s table of contents from Dublin while co-workers adjust formatting and make revisions from Denver. Instead of bombarding each other with attachments and hassling to reconcile people’s edits, your whole team can focus on productive work together.”

Download and home page for Google Cloud Connect for MS Office.
Read More:
Take a look at the movie in this post

Access SharePoint document libraries from Office

Problem: You can't save a word document to a SharePoint 2010 document library directly from word.  This applies to all products in the office suite and saving to SP2010 & MOSS from Windows Server 2008.  I was getting the error "You can't open this location using this program." when pointing the document to a SharePoint library.

Note: This only applies if your OS is Windows 2008 Server.

Initial Hypothesis: This only affects Windows 2008 Server users.  So it's really just developers looking at saving to SharePoint from the Windows 2008 Server environment, you would also need Office installed.  The issue is with the restricted access the Windows 2008 server allows by default.

Resolution:
Open Server Manager > Features > Add the "Desktop Experience" feature.  Andrew Woodward has a post on the issue for more information.
http://www.21apps.com/sharepoint/windows-server-2008-developing-sharepoint-cant-connect-from-office-clients/

AD account password out of sync with the managed service account within SharePoint

Problem: I am trying to start services on a server, when I start the Search Foundation service I get the following error: "The password for the account ...\..., as currently stored in SharePoint, is not the same as the current password for the account within Active Directory.  To fix this with Powershell, run Set-SPManagedAccount -UseExistingPassword."
Initial Hypothesis: The password for the account I am using to run the service using has been changed in AD, this does not match the password stored in the SharePoint.

Resolution: Reset the AD Password



Ensure SharePoint is using the correct pswd i.e. chnage the store managed account password as shown below using the Set-SPManagedAccount cmd.