Sunday, 24 April 2011

Referential Integrity between Lists

Problem: SP2010 adds referential integrity between lists using a lookup column.  I wish to push out cascade referential integrity between my lists using declarative CAML to build and link my 2 SharePoint lists.

Initial Hypothesis:  I am going to work through an example to highlight 2 key concepts when deploying a list declaratively using CAML (Using XML which is CAML I am declaratively creating 2 lists namely: Customers and Orders). 
1) I want to display a project field not the ID column that is doing the binding as my lists will make more sense to users updating them.  As shown below:

2)  Setup Cascade referential integrity between the lists (can't be done on the Site Column Lookup).  Referential integrity is done between list instances not on the Site Column.  Therefore, I use a feature receiver to wire up the referential integrity. The result of setting referential integrity is Shown as it will appear in the UI.

There are 3 ways to create lists namely: UI, programmatically or declaratively.  In MOSS the best option for lookup lists was to do it progratically using feature receivers.  My preferred approach is to use the declarative CAML approach.

Tip: The correct way to create a list is to ensure you have followed the 4 steps in this order using CAML: Site Columns, Content Types, List Definition & List Instance.

Tip: CKSDev is an VSIX extension that you can load into Visual Studio 2010 (VS2010) using Microsoft Gallery, it is a codeplex based project that adds functionality to VS2010.  You can use you "Solution Explorer" in VS2010, navigate to the site columns, right click and generate the CAML to declativtively build Content Types and Site columns.  So you can create the content types thru the UI then generate the CAML and now you have a repeatable mechanism of deploying content types and site columns. 

1) Lookup Field (Lookup Site column) should use the customer name not the default ID for linking (This actually links on the customer "ID" but the link displays the "Customers Name".  This is done on the field in the CAML using the attributes "ShowField" and "DisplayName".

2) The second point and title of this posts is about setting referential integrity between lists.  You cannot use the site column declaritive code to create the referential integrity.  The attribute "RelationshipDeleteBehaviour" is used to set the referential integrity behaviour, this can be either None (Default), Restrict or Cascade at a Site Column level.  Using the attribute "RelationshipDeleteBehaviour" does not work as shown below as referential integrity is done between list instances not on the site column.  Why the attribute "RelationshipDeleteBehaviour" is present I have no idea.

Add a new feature to the VS2010 sandbox solution project (Right Click "Features" in "Solution Explorer" and select "Add Feature")
Add the feature Receiver code (Right Click "Feature2" (or whatever you called it), select "Add Event Receiver".
Add the appropriate code to the feature receiver as shown below:
"You can apply a cascade delete rule. In this case, if a user deletes an item from a parent list, related items in the child list are also deleted. This helps to prevent orphaned items in the child list.
You can apply a restrict delete rule. In this case, users are prevented from deleting an item that is referenced by items in a related list. This helps to prevent broken lookup links in the data model." MSDN

Download the Visual Studio 2010 project that builds the 2 SharePoint lists in a sandbox solution and adds referential integrity to the list lookup relationship.

More Info:

Saturday, 23 April 2011

Where are Assemblies in Sandboxed Solutions Deployed?

I found this article on where Sandbox Solutions store their assemblies.   As I didn't know this thought I would share the info.

Assemblies (dll's) are packaged into Sandbox Solutions and deployed into the Solution Gallery of the Site Collection.  Sandbox solutions cannot work with local resources.   When the sandboxed solution is accessed for the 1st time, the wsp (sandbox solution) is unpacked and the dll's are copied to the file system for each server that handles the request to a file location specified on each servers SPUCHostService.exe (User Code Host Service), the default location is C:\ProgramData\Microsoft\SharePoint\UCCache
More Info:

Friday, 22 April 2011

On Holiday - Missionvale

Problem:  Yesterday I went to Missionvale in Port Elizabeth, South Africa. Missionvale is a charity registered in South Africa.  What a brilliant charity!  It's a micro charity so you can really see how every cent is spent which I like.  They work with a lot of HIV affected people.  Pretty dire situation these people are in, I really wish i could do more.

Initial Hypothesis:  Like all charities worldwide, Missionvale are struggling for funding.  This really is an amazing place.  I don't think a lot of South African's realise places like this exist.  I will gladly pass on any details if anyone would like to volunteer or make a donation.  They have some building projects over the next few months so if you are coming to SA, get in contact and help out or just come see the charity.  The children have little in terms of earthly goods but are happy playing.  My daughter played with them and it's great to see London hasn't influenced her ability to have fun with the children at Missionvale.

Resolution: My resolution is to help this charity more in the future.  Funding is a major concern especially as money for food is not really a focus in the world at the moment.  However, nutrition is key to helping Anti Retro Viral (ARV) drugs work.  There is a school at Missionvale that is being expanded where they feed and educate about 150 children.  I don't think anyone would argue with a feeding/nutrition program to help children learn.  These guys do so much I will definitely be donating more money in future and helping with events in the UK. 

Here are some of the children we saw.

What this has to do with SharePoint?  Well almost nothing except a lot of people read my blog, if you would like to find a charity, consider volunteering or making a donation this is a brilliant charity that is accountable (and audited by PWC).

More info:

Wednesday, 13 April 2011

IW User Group - JBG ToolFest

Yesterday I present Community Kit for SharePoint - Developer tools (CKSDev) as a tool for SharePoint 2010 developers to improve productivity at Microsoft in Johannesburg to the IW user group

CKSDEV is a great tool built by people in the SharePoint community and lives on codeplex.  I highly recommend CKSDev if you use VS2010 - it gives you so much extra functionality from within VS as a SharePoint developer.

My Impression of IW User group Jbg - Brilliant, I was amazed by the whole toolfest idea and think it's a good idea for user groups to follow.  Michael O'Donavan, Veronique Palmer and Rob MacLean are doing a great job for the SharePoint community in SA.  Good idea, great venue, smallish turnout.  SharePoint is flying in SA and the community is good. 

About ToolFest Jbg - This is the second toolfest that has been held in Jbg, I have no doubt there will be more as I learnt tons.  Rob MacLean showed Light Switch using SP lists (In my head i always call it LightBox - no idea why) - it was impressive.  All the presenters showed me new tips and tricks.  I have some thoughts on some of the presentations below:

Installing SP2010 using SPAutoInstaller, I knew Brian Edwards presentation on Brian Lala's Powershell autospinstall was key, all i can say is I wish I had thought of presenting this but alas there are always so many topics and CKSDev I am a big supporter of.  This looked at installing SP2010 using Powershell.  Anyway, Brian is a fellow from Benoni (I did most of my schooling on the East rand).  Brian raised the key point of installing SharePoint correctly using multiple managed accounts. The wizard is fine if you are small and don't have resource but it's an extremely simplified start that I am not a big fan of.  Here is a post on installation options in SP2010 - AutoSPInstaller from Brian Lala is my preferred option, this is under the PowerShell installation option.    Managed Accounts I use for SP2010 installations.
Update: 22/06/2011 - Current versio of AutoSPInstaller is 2.5, additionallly the codeplex project is called AutoSPIntaller not SPAutoInstaller as previously named.

Wicus van den Berg did a good session on upgrading to SP2010 using PS and scripts he build with a nice XML config file.  Also I was unaware of the Powershell ISE option, I use PowerGui but Powershell ISE is built in a looks to do a very good job.  I voted for Wicus - his 1st script failed which made the presentation even better as he showed why it's important to perform the upgrade using Powershell and allowing us to watch the variables returned.

All the presenters gave me info from learning about zipping for document library's to raising my awareness of content types in the eyes of enterprise users.  Workflow and SPD were discussed.  And Rober MacLean had an absolutely blinder with Light Switch - it was brilliant.  His claim to be the greatest person he knows - it may be true!  The reason some sessions are better covered are I feel I am better qualified to discuss these topics but I took a lot from all the presenters and speaking to people at the event.

Veronique Palmer the only SharePoint MVP in SA lead a session "How mature is your SharePoint implementation?" And Veronique walked us through the SharePoint Maturity Model, so this was interesting but the conversation and input from people with actual experiences was the real gem.  I got smashed out the park by a guy from a engineering background when I suggested Workspace easily had sufficient space for all the required documents when going offline.  Well I was wrong and I loved the way he told me.  why - Engineering company's in Africa have a unique set of challenges to say the least, many files, remote locations and absolutely huge files with a requirement for literally thousands of docs.  I said "Who would ever work on more than 500 document offline", now I know this does happen.

Summary:  I loved presenting and people asked me great questions about CKSDev.  The community in Johannesburg is going well.  I have been to a lot of SharePoint user groups and I can honestly say this is the best evening event I have participated in. 

Thursday, 7 April 2011

CKSDev My Favourite Features

Overview:  I love the codeplex project CKSDev.  This is the Community Kit for SharePoint 2010 - Developer Tools, it allows me to perform a lot of my tasks within Visual Studio 2010, it has a lot of templates I need and it has great local devlopment environment deployment tools.

Initial Hypothesis:  I estimate that I use 20% of the tools 80% of the time.  In this post I'm looking at what I use and like CKSDev to do for me.  The most important features for me revolve arround deployment.

1) Deploy code quickly - I use to use WSPBuilder for MOSS, all the features and more are now part of CKSDev.  You can deploy code, reset IIS, deploy to the root hive, all faster than do a full deployment from VS.
2) Turn on the Developer Dashboard - OK I run Powershell to turn on my dashboard but it can be done easily using CKSDev.  Using Solution explorer navigate to the Site collection, right click and select "Developer Dashboard", I set mine to "On Demand".
3) Sandbox templates - Ok CKSDev use to include an SPI template for Sandboxed Visual Web Parts, this has been retired and I now use the "Power Tools for SharePoint 2010" (VSIX).  The full trust proxy SPI template is needed to log my Sandbox solution exceptions.
4) Other SPI templates - branding, master pages, Custom Actions, SPMetal... a lot of useful templates.
5) SharePoint Reference Tab - I dislike having to navigate to find the SharePoint dll's when adding references to my projects.  CKSDev add a new "SharePoint" references tab.
6) Discovery/Explorer - Using the solutions explorer when CKSDev is installed I get to see more artifacts from the Site Collection.

Summary:  I highly recommend using CKSDev, it speeds up development for SharePoint 2010 developers considerably.

Tuesday, 5 April 2011

Timesheet for SharePoint 2010 CodePlex project

Overview:  I have a lot of people looking for a timesheet solution for SharePoint 2010 as I have 4 posts on this blog about timesheets for SharePoint.  I get some great pointers and requests so I think it is time to make this a codeplex project.
Objective: To make a plug-in for SharePoint that will allow users to fill in timesheets.  I recon a sandbox solution is a good idea with SharePoint Online on the horizon in the next few months.  I want to provide 2 storage providers for the data: SQL Server and AZURE.
Wanted: As a starting poing I am going to add my code onto CodePlex in the next week and hopefully some folks want to build this as a community project.  If you are interested in helping out please drop me a line.  I need C# coders & front-end devs (someone to be in charge of the UI would be great), testers, documenters, ideas.  So if you want to join the project you can twitter me at @paulbeck1 and I'll add you to the codeplex project pre-launch.!/PaulBeck1
Part 1 - Design & data storage
Part 2 - Building the UI
Part 3 - Installation Steps
Part 4 - Final Part

Saturday, 2 April 2011

Changing Password setting in AD using Group Policy

Problem: On my development machines i often don't want to have to change my password every 42 days or adhere to the default group policy setting for password when using AD.  I have multiple VM on multiple domains and changing passwords is a hassle.

Initial Hypothesis: Passwords are normally lost in one of three ways:
1) data breach
2) social engineering or phishing
3) malware
The following group policy helps open a machine in a dev environment but are obviously bad practice:
Change group policy to not change the default password after X days, disable password complexity, and remove password history.  Also allow users to change passwords immediately.  Use the Group Management Policy Editor on the AD machine.

Start > Run... > gpmc.msc
Navigate to the domain you wish to amend the group policy for (in my case it is
Right Click the default Group Policy as shown below and select "Edit"

Navigate Computer Configuration > Policies > Windows Settings > Security Settings > Account Policies > Password Policy.
Edit the Password Policy as you want it.
Save & Close the windows.
Run the windows command prompt (dos prompt): cmd>gpupdate