Sunday, May 19, 2013

Library/Lists enforcing versioning settings

So one thing that came up at one of the talks at 2013 Best Practices Conference for SharePoint was how to enforce or set the library/list version settings. The speaker was asking on if there was an easy way to set defaults to these settings, preferably without code.
I know this is a pain point, because I have admin a farm that had issues with versioning that is out of control. (ex. 15GB library with one document taking up 7GB of space. The file was only 15MB in size.)

No code solution

It will be assumed the reader has a good amount of experience with changing library settings, working with site settings, create templates(list and sites), and security within a site collection for no code solution.
Now there are a few ways to accomplishing setting the default values without coding, but there will be limitations. For instance, SharePoint has no control of how many draft versions an item can have. In my case, there was 2 major versions of the document 1 with 120 draft versions and the other 350+. So you will also need to make sure to set the Draft Item Security and/or the approval setting as well. This will making the users have to publish a major version. It also doesn't stop a owner/designer of the site to go into the settings of the library/list and change them either. But you can also create special permission levels to give you the autonomy to prevent this. The drawback is more admin work on your site.

How to do it


  • Create a new library/list based off of the template you want. 
  • Change the version settings set to the defaults(library/list settings > Versioning Settings)
  • Save this new library as a template in the library/list settings page.
  • Now simply create new lists/libraries with this template.
  • SharePoint Server (not foundation) you can go into the site settings and limit the templates that are allowable. Go to Site settings for this.

Drawbacks to this approach


  • You will have to replicate this template across all site collections. 
  • This doesn't affect existing lists/library. Manually (or with Powershell)  make the changes is required.
  • Doesn't stop owners/designer with permissions to make changes to this.
So what are the alternatives?

Powershell Approach

Powershell is a great tool for admins to get this enforce. A simple script can be created to go through all libraries and lists within the farm and make the necessary changes. Before doing this, I would advise first creating a script to inventory this information with what sites/webs are using it and want libraries/lists. There might be some libraries in the farm that shouldn't have the limits you are about to set applied (for legal or regulatory reasons). Best to verify with the teams that own the sites of what you are about to do. This way you can create a file of "exception to the rules" to bypass them when executing the final script. Also, you can set up this script to execute regularly with Windows Task Scheduler. Definitely test the script out first and verify everything is good, especially performance. You don't want to have your environment come to crawl because this script is running at peak times.

How to do it

There are a few articles/posting about scripts to accomplish this

Drawbacks 

  • Possible performance hit

Code approach

Talk with your SP Architect/SP Developers, they are the main people to consult about this. If they can't figure this out, then you might need to find one who can. But there a lots of options you can do for this:
  • List/library definitions - This is a simple coding exercise of creating the list/library definition with the elements.xml. Drawback is that it won't affect pre-existing libraries/lists. It also can be changed by owners/designers in the site collection.
  • Event receivers - Use the code to set the defaults and monitor any changes that are against the policies. This is not too bad of solution as(combining with Powershell) it will affect existing and new lists/libraries. Another implementation would be when an item gets added you can check how many draft versions are currently on the item and code something to either remove an older draft version or notify the user they should publish a major version soon.
If you are looking on how to code it use the c-sharpconer.com article above as that article has both the way to do it in C# and Powershell. 

Other approaches...

Find a 3rd party tool to do the job. I think Axceler's Control Point might be able to accomplish this. 
There is also a CodePlex project as well SharePoint Versioning Manager.
I do not endorse/advise to use either of these options. You should do the leg work and analysis with any tool to verify it meets your needs and doesn't cause issues with your environment. Just present both as options.

No comments:

Post a Comment