0

I am migrating a Sharepoint 2007 to 2010 but, SPLists that are created using a schema definition are not having their forms/views visual upgraded.

After much consideration and effort I've tried to replace the forms with new forms but it fails.

The new schema is already in place in the available templates and new lists are being created with the 2010 forms correctly. As a List that has already been instanced cannot have it's schema changed I suppose the only way to go is to instance a new list.

Is there anyone who has done this or knows a simple way to achieve this through code on a SPFeatureReceiver?

2
  • Isn't "After much consideration and effort I've tried to replace the forms with new forms but it fails." the actual root of you question? Maybe you should try to solve this, to properly migrate, or you will get tons of undesired side effects.
    – Steve B
    Nov 9, 2012 at 10:16
  • I know.. Have any idea on how to update a list schema or update its forms? Nov 9, 2012 at 10:32

2 Answers 2

1

We had migrated from MOSS 2007 to SPS 2010 and we were able to achieve it withoug any major issues, even we had custom list definitions. What we did was after migration wat to do a visual upgrade on the server, we changed all the list view webparts to XSLTListView webpart, upgraded the master page to 2010 version new master page and applied to the migrated sites. This gave the similar 2010 look and feel.

4
  • How did you do the webpart exchange? I have changed the system masterpage to "v4.master" and have the custom front end master page on primary. Nov 9, 2012 at 10:41
  • The SharePoint object model access the page, remove the webpart and add a new instance of XSLTWebPart by setting the properties taken from the old webpart
    – Manju
    Nov 9, 2012 at 10:45
  • Do you have code available? It would help me a lot... Nov 9, 2012 at 10:53
  • I could not add the code in comments section, i am adding as answer
    – Manju
    Nov 9, 2012 at 11:39
1
                                         SPLimitedWebPartManager webMgr = web.GetLimitedWebPartManager(strPageName, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                                         web.AllowUnsafeUpdates = true;
                                         foreach (Microsoft.SharePoint.WebPartPages.WebPart wp in webMgr.WebParts)
                                         {

                                             if (wp.GetType().ToString().ToLower() == "microsoft.sharepoint.webpartpages.listviewwebpart")
                                             {
                                                 try
                                                 {


                                                     ListViewWebPart listWP = (ListViewWebPart)wp;
                                                     Microsoft.SharePoint.WebPartPages.XsltListViewWebPart xsltListWP = new XsltListViewWebPart();
                                                     xsltListWP.ListId = listWP.ListId;
                                                     xsltListWP.Title = listWP.Title;
                                                     xsltListWP.TitleUrl = listWP.TitleUrl;
                                                     xsltListWP.ToolTip = listWP.ToolTip;
                                                     xsltListWP.ViewId = listWP.ViewId;
                                                     xsltListWP.TitleIconImageUrl = listWP.TitleIconImageUrl;
                                                     xsltListWP.ZoneID = listWP.ZoneID;
                                                     xsltListWP.PartOrder = listWP.PartOrder;
                                                     xsltListWP.XmlDefinition = listWP.ListViewXml;
                                                     tobeAdded.Add(listWP.ID, xsltListWP);
                                                     tobeDeleted.Add(listWP.ID, listWP);
                                                 }
                                                 catch (Exception ex)
                                                 {
                                                     Utilities.LogToConsole("Exception occured while converting webpart : " + wp.Title + DateTime.Now.ToString("dd MM YYYY HH:mm:ss"), false);
                                                 }
                                             }
                                         }


                                         //add webpart
                                         foreach (string key in tobeAdded.Keys)
                                         {
                                             try
                                             {
                                                 bool addSucceeded = true;
                                                 Microsoft.SharePoint.WebPartPages.WebPart webPartTobeDeleted = (Microsoft.SharePoint.WebPartPages.WebPart)tobeDeleted[key];
                                                 Microsoft.SharePoint.WebPartPages.WebPart webPartTobeAdded = (Microsoft.SharePoint.WebPartPages.WebPart)tobeAdded[key];

                                                 //To add the webpart in webpart manager
                                                 try
                                                 {
                                                     webMgr.AddWebPart(webPartTobeAdded, webPartTobeDeleted.ZoneID, webPartTobeDeleted.ZoneIndex);
                                                 }
                                                 catch (Exception innerExp)
                                                 {
                                                     errCount++;
                                                     Utilities.LogToConsole("An exception occured while Adding webpart: " + webPartTobeAdded.Title + " for the site : " + web.Url.ToString() + " at the page: " + strPageName + " Exception Message " + innerExp.Message + DateTime.Now.ToString("dd MM YYYY HH:mm:ss"), false);
                                                     addSucceeded = false;

                                                 }
                                                 if (addSucceeded)
                                                 {
                                                     if (webPartTobeDeleted.IsClosed)
                                                     {
                                                         webMgr.CloseWebPart(webPartTobeAdded);
                                                     }
                                                     if (webPartTobeDeleted.FrameState == FrameState.Minimized)
                                                     {
                                                         webPartTobeAdded.FrameState = FrameState.Minimized;
                                                     }

                                                     webMgr.DeleteWebPart(webPartTobeDeleted);

                                                     //saving changes for close and minimize
                                                     webMgr.SaveChanges(webPartTobeAdded);
                                                 }




                                             }
                                             catch (Exception ex)
                                             {
                                                 errCount++;
                                                 Utilities.LogToConsole("An exception occured while Closing webpart: " + ((Microsoft.SharePoint.WebPartPages.WebPart)tobeAdded[key]).Title + " for the site : " + web.Url.ToString() + " at the page: " + strPageName + " Exception Message " + ex.Message + DateTime.Now.ToString("dd MM YYYY HH:mm:ss"), false);

                                             }


                                         }
2
  • this code will cause the change on the underlying aspx? I mean the one that we configure in list schema, view element "SetupPath"? Nov 9, 2012 at 12:12
  • It will just remove existing webpart in a given page and replace with a new XSLTListViewWP. It will not do any changes to xml schema
    – Manju
    Nov 15, 2012 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.