I have a SharePoint library with the following folder structure pr. Customer:

Customer 1, subfolder1=Products, subfolder2=Tests, subfolder3= Trades

Customer, 2 subfolder1=Products, subfolder2=Tests, subfolder3=Trades


I wish to add a Retention Policy to each of the Trades folders. I want to do this using code whenever a new Trades folder is created.

Searching Google i found that it is possible to create the retention policy using code: https://blogs.msdn.microsoft.com/jfrost/2011/03/15/setting-custom-expiration-programmatically/ and add it to a folder level: https://msdn.microsoft.com/en-us/library/ee571406.aspx

How do can i write code to trigger this whenever a new Trades folder is created in the library?

Does anyone know if this is possible in SharePoint Server 2016. All documentation is in SharePoint 2010.

  • The code used to achieve that in 2016 should be almost (if not completely) identical to 2010/2013. Commented Dec 22, 2016 at 12:53
  • Thank you. Do I need to create a Solution to trigger on creation of a new item in the list, or how do I implement the code? Commented Dec 28, 2016 at 7:09

1 Answer 1


I can only speak of my experience on SP 2013, without using code, but maybe it is relevant.

On the site collection level go to settings/Site Collection Admin/Content Type Policy Templates/select 'Enable Retention'/'add a retention stage'. If you configure the policy based on content types it would give you the flexibility to only apply the retention policy on the 'Trades' content type.

It sounds like you've already done some background reading on this, but you might want to refer to Kim Frehe's excellent post.

Since the retention policy is set at the site collection level, every document library in the site collection should be 'inheriting' the policy, therefore when a new folder is created the policy should be inherited there too, unless you configure SP to behave differently.

Finally, you will need to activate the relevant Features (Site Collection Admin/Site Collection Features), I don't know offhand which ones are automatically activated. You may need 'Disposition Approval Workflow' (allows a task to be generated once a document has 'expired' - i.e. the criteria you specified are fulfilled e.g. 'modified date +1 year' makes a review task. Other Features you may require are 'In Place Records Management' and 'Library and Folder Based Retention'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.