Programmatically add new version of a Sitecore item

Programmatically add a new version of an item in Sitecore

This is a pretty easy concept but lately I've been hearing that most of the blog posts generated don't really help beginners new to Sitecore. I decided that I would occasionally slip in a basic concept for the beginners. First in the series: Programmatically adding a new version of a Sitecore item.

Use case: My intranet website now allows employees (with proper permissions) to edit project details within the intranet site. The thing that scared me about this approach was that I could easily envision an employee overwriting the field value and having their boss say - "why did you update that, please go back to previous copy"

So when an employee edits the item from the website, I create a new version of the item. This allows me to roll back to the older version when needed. The code is really simple too.

//disable security - optional step
using (new Sitecore.SecurityModel.SecurityDisabler())
 //create new version of item that you are editing
 Item LatestItemVersion = ItemToVersion.Versions.AddVersion();
 //Begin Editing
 //do something to item
 //End Editing


  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in SITECORE , kindly Contact MaxMunus
    MaxMunus Offer World Class Virtual Instructor led training on SITECORE. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 1,00,000 + trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Saurabh srivastava
    Skype id: saurabhmaxmunus


Post a Comment