Home > SharePoint > How to perform feature upgrade in SharePoint2010 part2

How to perform feature upgrade in SharePoint2010 part2

In my last post, I showed you how to perform feature upgrade and upgrade my feature from 0.0.0.0 to 1.0.0.1. In this post, I’d like to continue on this topic and upgrade the feature again.

For the first version of my solution, I deploy a document library with a custom document set content type and then upgrade the solution so I index the application number column. Now , I will create a new version of the solution so that it will remove the threshold of the list. 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. The version 1.1 will be in the Upgrade folder and version 1.2 will be in the Upgrade2 folder.

You need to make the following changes to the existing solution.

1. Modify the ApplicationLibrary.Template.xml as highlighted below:


2. Adding the following code into the feature event receiver.

</pre>
public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
 {
 base.FeatureUpgrading(properties, upgradeActionName, parameters);
 SPWeb web = GetFeatureWeb(properties);
 SPList applicationLibrary = web.Lists.TryGetList(ApplicationLibraryNamesConstant.ApplicationLibraryName);

switch (upgradeActionName)
 {
 case "IndexApplicationNumber":
 if (applicationLibrary != null)
 {
 SPField queueField = applicationLibrary.Fields["ApplicationNumber"];
 queueField.Indexed = true;
 queueField.Update();
 }
 break;
 case "RemoveListThreshold":
 applicationLibrary.EnableThrottling = false;
 applicationLibrary.Update();
 break;

 }
 }
<pre>

3. Package your solution and run the feature upgrade PowerShell script.


$wspFolder ="v1.2"
$scriptPath=Split-Path $myInvocation.MyCommand.Path
$siteUrl = "http://ybbest"
$featureToCheckGuid="1b9d84cd-227d-45f1-92d4-a43008aa8fe7"
$requiredFeatureVersion="1.0.0.1"
$siteUrlOfFeatureToBeChecked="http://ybbest"
AppendLog "Starting Solution UpgradeSolutionAndFeatures.ps1" Magenta
& "$scriptPath\UpgradeSolutionAndFeatures.ps1" $siteUrl $wspFolder $featureToCheckGuid $requiredFeatureVersion $siteUrlOfFeatureToBeChecked
Write-Host

AppendLog "All features updated" "Green"

References:

Feature upgrade.

Advertisements
Categories: SharePoint
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: