Saturday, February 21, 2009

Microsoft SharePoint 2007 - SharePoint Lookup Field Relinker Utility

I've had a dig into my code stash, and found that I actually have a tool to help reassociate SharePoint lookup fields to lists. You'd only every really need to reassociate if the list referenced by the lookup field has an altered GUID. The GUID of a list would change if it has been deleted, or if you migrate a list from one environment to another.

I'm quiet flat out atm, so I'll post some more information in the next week or so with instructions on how to use this tool.

This tool was used as part of a migration plan across servers using site backup and restore. The restored site ended up with lists that had lookups that did not associate with the appropriate columns. This is because the ID of the list in the new environment is different after a restore. Therefore the stored lookup field definition will no long be validly pointing to the correct ID of the list column that it was associated with - hence the need for this tool to reassociate such lookup fields with the relevant list columns that it references from.

Hopefully this little tool could help save alot of pain in migrating lookup fields in lists.

Some notes on the utility:
This tool was developed to reassociate or fix SharePoint lookup fields to lists in a site.

This tool is able to:
1. Relink lookup fields
2. Relink multiple lookup fields from an XML definition (Bulk tasks)
3. View Field Schema

This tool is useful in the following scenarios:
1. A list a lookup field is pointing to has been deleted and needs to be linked to a different field in a different list
2. A site backup is made and is restored in a different environment - The lookup fields will no longer link to
the field even thought the appropriate lists may be created. This tool will help relink the fields

Requirements for this tool to run:
1. Must login as Site Administrator - as the code will delete the lookup field and recreate it (Did not use RunWithElevatedPrivileges() for security purposes.)
2. Tool must be run on a WSS v3.0 or MOSS 2007 Server directly
3. Sorry, this tool has only been tested on an English environment - but theoretically should still work
with other localisations of SharePoint instances.

Where to download:


Mondo said...

Can you elaborate on how to use please.

elizas said...

First of all we need to know a little on SharePoint lookup fields before proceeding further. Lookup fields are the reference fields created in any SharePoint list or library which provides a mapping between columns from another list i.e. it is just like a foreign key which helps build relationship between lists.While developing custom solutions there is often a need to retrieve data from a list or update data in a list but it's a bit different when the task is performed for a lookup field. Generally lookup data are stored as ID - Name pair separated with some special characters (i.e. ID;#Name).