Thursday, February 26, 2009

Recreating a Column in SharePoint's User List

I did something really stupid. I wanted to customize the columns in the User Information List and decided that I did not need the Department column. Normally you can't delete the Department column, but a quick Google search pointed me to a tool called SharePoint Manager 2007(SPM). Using SPM, I was able to change the flag that was preventing me from deleting the Department column. Less than two minutes after deleting the Department column I started getting complaints about errors when trying to edit list items. It turns out that you really can't delete the Department column. What made this mistake even more stupid was that I did not make a backup of the site before playing with the User Information List.

The first thing I tried was to recreate the column with the web interface. Even if you name the column "Department", there is something different and you are still left with a broken site. After weeks of digging through Google and analyzing the SharePoint database, I was finally able to discover a method to create the original Department column and fix my errors. What made my fix possible were the export, import and update field tools created by Gary Lapointe.

Here are the steps I followed:
  1. Create new site collection with a new top level site. This creates a new User Information List with the Department column.
  2. Run gl-exportlistfield on the new site to get the XML for the department column. The command I used was:
    stsadm -o gl-exportlistfield -url "http://sharepoint:1234/_catalogs/users/detail.aspx" -fielddisplayname "Department" -outputfile "c:\backups\usersList"

  3. Run gl-importlistfield on the broken site to recreate the department column. The command I used was:
    stsadm -o gl-importlistfield -url "http://sharepoint/_catalogs/users/detail.aspx" -inputfile "c:\backups\usersList"
After running those two commands, the Department column was restored and my errors were resolved. Gary Lapointe has created some very useful addons to the stsdm command line tool. His blog is a must read for anyone managing a SharePoint server. More information can be found on his blog at http://stsadm.blogspot.com/.

1 comment:

  1. Great article - it's always good to see a creative solution to an issue every Sharepoint admin can run into.

    ReplyDelete