How to perform feature upgrade in SharePoint2010 part1
Posted
by ybbest
on YBBest
See other posts from YBBest
or by ybbest
Published on Wed, 21 Nov 2012 10:01:35 +0000
Indexed on
2012/11/22
11:15 UTC
Read the original article
Hit count: 599
Once your custom SharePoint solution went into production. Any changes made to it require you to perform feature upgrade. Today, I’d like to show you how to perform feature upgrade.
For the first version of my solution, I deploy a document library with a custom document set content type. You can download the solution here. Once you extract your solution, the first version is in the original folder. In order to deploy the original solution, you need to run the sitecreation.ps1 in the script folder.
Next, I will modify the solution so that I will index the application number in the document library I just created in my original solution.
1. Modify the ApplicationLibrary.Template.xml as highlighted below:
2. Adding the following code into the feature event receiver.
public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters) { base.FeatureUpgrading(properties, upgradeActionName, parameters); SPWeb web = GetFeatureWeb(properties); switch (upgradeActionName) { case "IndexApplicationNumber": SPList applicationLibrary = web.Lists.TryGetList(ApplicationLibraryNamesConstant.ApplicationLibraryName); if (applicationLibrary != null) { SPField queueField = applicationLibrary.Fields["ApplicationNumber"]; queueField.Indexed = true; queueField.Update(); } break; } }
3. Package your solution and run the feature upgrade PowerShell script.
$wspFolder ="v1.1" $scriptPath=Split-Path $myInvocation.MyCommand.Path $siteUrl = "http://ybbest" $featureToCheckGuid="1b9d84cd-227d-45f1-92d4-a43008aa8fe7" $requiredFeatureVersion="0.0.0.0" $siteUrlOfFeatureToBeChecked="http://ybbest" AppendLog "Starting Solution UpgradeSolutionAndFeatures.ps1" Magenta & "$scriptPath\UpgradeSolutionAndFeatures.ps1" $siteUrl $wspFolder $featureToCheckGuid $requiredFeatureVersion $siteUrlOfFeatureToBeChecked Write-Host AppendLog "All features updated" "Green"
Note:
If you have not version your feature explicitly , your feature version will be 0.0.0.0 .
References:
© YBBest or respective owner