Overview

The RDA List Referential Integrity Solution shows how to ensure basic referential integrity for SharePoint lists.

Problem

SharePoint users can create a relationship between lists using the Lookup field. For example: in the Employees list we can define the Department field as a Lookup into the Departments list using the field Title. To abbreviate this: Employees"Department" references Departments"Title". Now when the user is creating or modifying an entry in the Employees list, the Department field get a nice drop-down list of all Departments. There are two ways this can be broken. If there are two entries in the Departments list with the same Title, it is hard to tell which instance is referenced by the existing Employees entries. Also, it is possible to delete the referenced Department entry which leaves us with orphaned Employee entries.

Solution

RDA List Referential Integrity Feature to the rescue! Using this solution helps with both problems.

How it works

When activated, the Feature creates a list named ReferentialIntegrity. The activation code iterates through all lists on the site and adds entries to the ReferentialIntegrity list for all existing Lookup fields (i.e. there is one entry for each relationship between two lists). The code also creates and attaches List Event Receivers that monitor if Lookup fields are added to existing lists. Finally, the code creates and attaches Item Event Receivers that prevent users from adding/modifying/deleting list items if it would violate referential integrity by creating one of the problems mentioned above.

Installation Instructions

Install the .wsp solution using stsadm and deploy it to the web application of your choice using stsadm or the Central Administration UI.

Once deployed, the RDA List Referential Integrity is available in the Site Features section of the Site Settings.

Last edited Sep 23, 2008 at 11:26 AM by RDACollaboration, version 1

Comments

No comments yet.