Versioning attachments in a SharePoint list – an implementation

Further to the post on the 14th of October, here is a complete implementation of versioning attachments in a SharePoint list as a Visual Studio 2010 project.

Once the .wsp has been built and deployed, it can be activated at the web scope. Once this is done, on all lists an item called “List attachment versioning” appears on the List Settings page. When accessed this allows the user to switch attachment versioning on or off. This in turn will create a hidden document library and hidden fields as necessary to support the attachment versioning.

Please do try it and let me know what you think.

Download the solution here.

Update: 17/11/2011 – Error fixed where the solution only works on a root site.

10 Responses to “Versioning attachments in a SharePoint list – an implementation”

  1. Hi Tim,

    Thanks for the nice solution. i deployed your soultion on my site. everything working properly except one thing.The problem is once i restore the preveious version of the item then the current version item attachment does not get removed. preveious version item attachment and current version attachment both comes. Please look into it.

    Manoj kumar rai

  2. Hi Tim,

    I tried again. But it’s not working properly.i have sharepoint server 2010 installed on my PC.

  3. I like your overall approach, but your code doesn’t work. Installing the WSP and activating the Attachment Versioning feature works well. It enables the List attachment versioning option on each list. When you enable versioning for a list, however, SharePoint throws an exception:

    System.ArgumentException: Invalid field name. {e9ba260d-4335-4d71-a949-babcd0a1e95c}

    It’s the VersionLabel field which you add to each list that cannot be found.

    By the way: how come you create a separate document library for storing versions? Why not add a Versions folder to each list and store each version as a subfolder. I’m a bit concerned by the way you tag each file in the document library with the versions for which it’s relevant (like 1.0;2.0;3.0). I’m not sure your code handles the case of a user first deleting an attachment and then, versions later, adding an attachment with the same name. It seems more robust to store all files related to a version in a separate folder, though it requires more space.

    Let me know what you think.

  4. To be exact, enabling versioning for a list only works on a root site. Also, your code doesn’t properly support removing and adding a file with the same name. The VersionLabel for the file becomes “;1.0;;2.0;;1.0”.

    • Hi Ronnie,

      Thanks for your comments; you’re right the version uploaded was a bit premature; I’ve actually since updated the solution to take care of a lot of these edge cases. Like you mention in your article it’s not an ideal way to take care of things, but unfortunately there’s little in the event hierarchy that we can tap into to help us in this case.

      To take care of some of these I had to rather than tie a specific file to a specific version, is two a specific version of a file to a specific version of a list item – thus handling removing and adding the file with the same name; these have been implemented as a commercial solution for some of my clients.

      Hopefully I’ll get round to packaging a more robust version and putting it on the site; for now I’ll aim to fix the one that is there!


  5. Hi!
    I deployed your solution on SharePoint Foundation 2010 Hungarion version, but if I try set Attachment versioning enabled? to YES, I receive a mistake: Invalid field name: {e9ba260d-4335-4d71-a949-babcd0a1e95c}
    Please help!

    Niki from Hungary


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: