Share via


Upgrade issue from SPS2003 to MOSS2007

When you upgrade your SharePoint environment from SPS2003 to MOSS 2007 and if you have a “General Discussion” list, you will get “null” in the “Last updated” field because is SPS2003 there is no such field named “Last Updated” exists. You will get “Modified” in field “General Discussion” List of the older version of SharePoint. If you add a new item in the list, you will get the latest values in both the column. So if you would like to replace “Last Updated” column values with “Modified” values, you can use the following code:-

 

    1:  using System;
    2:  using System.Collections.Generic;
    3:  using System.Text;
    4:  using Microsoft.SharePoint;
    5:   
    6:  namespace UpdateDiscussionListColumn
    7:  {
    8:      class Program
    9:      {
   10:          static void Main(string[] args)
   11:          {
   12:              Console.WriteLine("Enter your SharePoint site URL :");
   13:              string strUrl = Console.ReadLine();
   14:   
   15:              Console.WriteLine("Enter your Discussion List name :");
   16:              string strDListName = Console.ReadLine();
   17:   
   18:              SPSecurity.RunWithElevatedPrivileges(delegate()
   19:              {
   20:                  using (SPSite oSite = new SPSite(strUrl))
   21:                  {
   22:                      using (SPWeb oWeb = oSite.OpenWeb())
   23:                      {
   24:                          SPList oList = oWeb.Lists[strDListName];
   25:   
   26:                          foreach (SPListItem oItem in oList.Folders)
   27:                          {
   28:                            
   29:                              if(oItem["Last Updated"] == null)
   30:                              {
   31:                                Console.WriteLine("old values");
   32:                                oItem["Last Updated"] = oItem["Modified"];
   33:                                oItem.Update();
   34:                                Console.WriteLine("New values" + oItem["Last Updated"].ToString());
   35:                              }
   36:                          }
   37:                          oList.Update();
   38:                      }
   39:                  }
   40:              });
   41:   
   42:              Console.WriteLine("Operation completed successfully");
   43:              Console.ReadLine();
   44:   
   45:          }
   46:      }
   47:  }

Comments