none
Invoking the feature upgrade method while upgrading a site collection from SharePoint 2010 to 2013 RRS feed

  • Question

  • We are trying to run custom code within the upgrade event of a custom feature which has already been activated in a 2010 site collection.

    When the site is upgraded from 2010 to 2013, the upgrade event for the custom feature is not getting invoked.

    Should this event be triggered, explicitly through some custom code or power shell script

    I assumed that the SharePoint upgrade timer job would trigger this for me.

    Friday, August 30, 2013 12:56 AM

Answers

  • Hi Jasdeep,

    To automate the process, you can schedule a powershell script that periodically checks for the sites that have finished upgrading and upgrade its features. Following are the steps to create a simple powershell script to automate this process-

    1) Find the site collections in the farm (or content db based on your situation) that have finished upgrading using powershell-
       For ex:
    Get-SPSiteUpgradeSessionInfo -ContentDatabase <DatabaseName> -ShowCompleted

    2) For each of the sites returned in previous step,  query the features that require an upgrade (can add custom logic/filter too) and perform the upgrade. Also, after upgrading features, set a site level property bag to indicate that its features have been upgraded so that next time you can eliminate the site from your feature query nicely. Following
     links will help you do it -

    http://www.sharepointnutsandbolts.com/2010/08/feature-upgrade-part-5-using-powershell.html
    https://www.nothingbutsharepoint.com/sites/itpro/Pages/SharePoint-QueryFeatures-issue-when-performing-a-feature-upgrade.aspx
    http://sharepoint.stackexchange.com/questions/21324/editing-property-bag-values-using-powershell


    3) In scheduler, add your powershell script as a scheduled job to run at a defined schedule.

    Hope it solves your issue.

    Regarding your question, I haven't checked why MS doesn't upgrade custom features as part of its upgrade process. You can find it easily by checking the code of the timer job (Create Upgrade Evaluation Site Collections job ) responsible for feature upgrade using Reflector.

    Narahari

    ******If a post answers/helps your question, please click "Mark As Answer" on that post and/or "Vote as Helpful*******


    Wednesday, September 4, 2013 4:32 AM

All replies

  • Hi Jasdeep,

    Use powershell (Upgrade-SPFeatures) or custom code to trigger the update. Follow the article below for sample code -

    http://www.sharepointnutsandbolts.com/2010/08/feature-upgrade-part-5-using-powershell.html

    Narahari

    ******If a post answers/helps your question, please click "Mark As Answer" on that post and/or "Vote as Helpful*******

    Friday, August 30, 2013 6:10 AM
  • Hi Narahari,

    Although this method of invoking the feature upgrade works. With this, I will not be able to automate the feature upgrade invocation after the site collection is upgraded.

    I expected SharePoint upgrade timer job to do this for me. The OOB features get upgraded when a site collection upgrade is initiated.

    Why not the custom features?

    Saturday, August 31, 2013 12:25 AM
  • Hi Jasdeep,

    To automate the process, you can schedule a powershell script that periodically checks for the sites that have finished upgrading and upgrade its features. Following are the steps to create a simple powershell script to automate this process-

    1) Find the site collections in the farm (or content db based on your situation) that have finished upgrading using powershell-
       For ex:
    Get-SPSiteUpgradeSessionInfo -ContentDatabase <DatabaseName> -ShowCompleted

    2) For each of the sites returned in previous step,  query the features that require an upgrade (can add custom logic/filter too) and perform the upgrade. Also, after upgrading features, set a site level property bag to indicate that its features have been upgraded so that next time you can eliminate the site from your feature query nicely. Following
     links will help you do it -

    http://www.sharepointnutsandbolts.com/2010/08/feature-upgrade-part-5-using-powershell.html
    https://www.nothingbutsharepoint.com/sites/itpro/Pages/SharePoint-QueryFeatures-issue-when-performing-a-feature-upgrade.aspx
    http://sharepoint.stackexchange.com/questions/21324/editing-property-bag-values-using-powershell


    3) In scheduler, add your powershell script as a scheduled job to run at a defined schedule.

    Hope it solves your issue.

    Regarding your question, I haven't checked why MS doesn't upgrade custom features as part of its upgrade process. You can find it easily by checking the code of the timer job (Create Upgrade Evaluation Site Collections job ) responsible for feature upgrade using Reflector.

    Narahari

    ******If a post answers/helps your question, please click "Mark As Answer" on that post and/or "Vote as Helpful*******


    Wednesday, September 4, 2013 4:32 AM
  • Hi Narahari,

    Thanks for your response. 

    For now I would be doing something similar to what you have provided. 

    Also, shall keep you posted in case I find something with the reflector.


    Wednesday, September 4, 2013 12:10 PM
  • Hi Jasdeep,

    I m glad that the above solution helped you. Looking forward to your analysis from reflector.

    Narahari 

    Thursday, September 5, 2013 1:59 PM