Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 at 10:16
    
I know.. Have any idea on how to update a list schema or update its forms? –  TheBigCheese Nov 9 '12 at 10:32

2 Answers 2

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.

share|improve this answer
    
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. –  TheBigCheese Nov 9 '12 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 '12 at 10:45
    
Do you have code available? It would help me a lot... –  TheBigCheese Nov 9 '12 at 10:53
    
I could not add the code in comments section, i am adding as answer –  Manju Nov 9 '12 at 11:39
                                         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);

                                             }


                                         }
share|improve this answer
    
I will teste it. Thanks! –  TheBigCheese Nov 9 '12 at 11:59
    
this code will cause the change on the underlying aspx? I mean the one that we configure in list schema, view element "SetupPath"? –  TheBigCheese Nov 9 '12 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 '12 at 9:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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