Friday, March 25, 2011

How to restore SharePoint 2010 Site Templates especially for Sites migrated from MOSS

After much painful debugging, I managed to resolve the issues related to Site Template save and restore for SharePoint 2010 based Sites. I noted that the SharePoint 2010 site itself had corrupted lists "Calendar", “Issue” etc (which does not get migrated properly from MOSS), which I had to delete and then created a new lists (such as “IssuesRegister”) in SharePoint 2010 and painfully relinked all workflows, data views, dispforms etc. I also deleted all the master pages (starting with clarity_) and styles library as they were remains from MOSS/SharePoint Online instance and was causing incompatibility issues. Anyways after all this, I saved the site as Site Template and EUREKA IT WORKED!!

Once I got the Site Template, I restored the site on new server and got a series of missing features exceptions (with correlation IDs - for example "The site template requires that the Feature {e34b0b8e-6e21-49ad-8d2f-530a29d61175} be installed on the farm or site collection"). I painfully debugged through each missing feature ID and learned the following (in a very painful way again)
1)   Ensure that all Site Collection and site Features in Source and Destination SharePoint servers are identical.
2)   I used the Powershell script Get-SPFeature -Site <Site Collection name> | Sort Id | FT DisplayName,Id to get all features deployed and matched against the list of feature names from here against the corresponding missing feature complained by SharePoint 2010 on the new box. Once I identified the feature missing, I went ahead and enabled the feature (see point 2 below)
3)      The Following features are required for restoring all SharePoint 2010 Site Templates that were migrated from MOSS (For e.g. - http://shp2010test is the new server where I tried restoring the new site based on SharePoint 2010 Template) – USING POWERSHELL:
a.       Enable-SPFeature LocalSiteDirectorySettingsLink -Url http://shp2010test
b.      Enable-SPFeature InPlaceRecords -Url http://shp2010test
c.       Enable-SPFeature SignaturesWorkflow -Url http://shp2010test
d.      Enable-SPFeature HelpLibrary -Url http://shp2010test
e.      Enable-SPFeature LocationBasedPolicy -Url http://shp2010test
f.        Enable-SPFeature OpenInClient -Url http://shp2010test
g.       Enable-SPFeature MobileExcelWebAccess -Url http://shp2010test
h.      Enable-SPFeature TaxonomyFieldAdded -Url http://shp2010test
4)      Strangely there was no theme applied to new site and so I had to reset the theme on this new site to inherit from parent and EUREKA! The site was live and all workflows seems to be working ok!

Anyways all my pain and suffering today would hopefully lead to more seamless and easy migration from SharePoint 2007 to SharePoint 2010 and then moving migrated sites between SharePoint 2010 servers.

Sunday, March 13, 2011

Hide List Columns on Display, Edit and New Forms using JQuery

Follow the steps below to quickly hide List Columns on Display, Edit and New Forms using JQuery:
1) Create a scripts library in your site (or use the one you currently use to store your Javascript/*.js files)
2) Download the latest version of the JQuery file from here - http://code.jquery.com/jquery-1.5.1.min.js
3) Copy the above *.js files (namely "jquery-1.5.1.min.js") to the scripts folder created in Step 1
5) Open the form/page (such as NewForm.aspx or EditForm.aspx) where you want to hide editable list columns and add the following script at the end of the page (preferably below the end </style> tag:


<script language="javascript" type="text/javascript" src="/board/scripts/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
  $(nobr:contains("All Day Event")').closest('tr').hide();

});
</script>
6) Ensure that you replace the List Column name that you want to hide in the above script sample
7) Also note that on DispForm.aspx, you need to slightly modify the above script and look for "h3" tag instead of "nobr" tag in the above script

Auto populate current logged in user name in SharePoint 2010 People Picker control

Follow the steps below to Auto populate current logged in user name in SharePoint 2010 People Picker control:
1) Create a scripts library in your site (or use the one you currently use to store your Javascript/*.js files)
2) Download the latest version of the JQuery file from here - http://code.jquery.com/jquery-1.5.1.min.js
3) Dowload the latest version of the SPServices JQuery library from here - http://spservices.codeplex.com or http://spservices.codeplex.com/releases/55660/download/171214
4) Copy the above *.js files (namely "jquery-1.5.1.min.js" and "") to the scripts folder created in Step 1
5) Open the form/page (such as NewForm.aspx) where you want to default the People Picker control to the current user logged in and add the following script at the end of the page (preferably below the end style tag:


<script language="javascript" type="text/javascript" src="/board/scripts/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript" src="/board/scripts/jquery.SPServices-0.6.0.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
 var userName = $().SPServices.SPGetCurrentUser({
  fieldName: "Name"
 });
 $("textarea[title='People Picker']").val(userName);
 $("div[title='People Picker']").text(userName);
});
</script>








Note - you need to replace the src property values above to reflect the correct path to the Javascript files downloaded in above steps and saved in the "scripts" folder.