views:

24

answers:

3

Hi,

We currently have a field which has the wrong ID. the IDs and Internal Names of Sharepoint Fields are readonly on the domain model. I was wondering if there is a way to update them even by using the content database.

One sure way is to delete the field and recreate it. but it already has data and there are thousands of pages. I was wondering if there is a way just to update the IDs and Internal Name without doing the dropping and recreation of fields.

Thanks

+2  A: 

Even if it may work, don't do it.
It's:

  • Dangerous, as you may skip dependencies
  • Not supported

Recreating the field using some script to keep data is safer.

Nico
A: 

We ran into the same problem. Messing with the DB was not an option for us (and shouldn't be for you either), but you can work around it. Unfortunately, it will require touching each page to update the metadata.

First, create the column like it should be in the list. Then, you can copy the data from the old column to the new column in a variety of ways:

  1. DataSheet view
  2. Programmatically via web services (don't need to have access to the server)
  3. Programmatically via console app (will need to run locally on the server)

Honestly, writing a small console app will be the quickest. For example:

string siteUrl = "http://server/sitecollection/";
string webUrl = "subsite1/subsite2/";
string listName = "Your List Name";
using (SPSite site = new SPSite(siteUrl))
{
    using (SPWeb web = site.OpenWeb(webUrl))
    {
        SPList list = web.Lists[listName];
        foreach (SPListItem item in list.Items)
        {
            item["New_x0020_Column_x0020_Name"] = item["Old_x0020_Column_x0020_Name"];
        }
    }
}

Also, it would HIGHLY recommend trying this in a DEV environment first. Just do an STSADM restore from your production environment and test your console app. Then, validate your data and delete the old column!

Kit Menke
A: 

I would not suggest modifying the content database, since it is:

  • unsupported (if you do it, Microsoft will not help you when you're in real trouble even if you have MS Premier Support)
  • very complicated to do. You'd have to update a number of tables and you would never be sure if you actually updated all the required things.

What you can try to do - see if the internal name property is actually "read only" or it is defined as "friend" and you cannot call it from a different code assembly. If it's the latter case, you can use .Net reflection to set the property value. See this MSDN documentation link for details.

naivists