A Case for Controlled Folders using Microsoft Flow (with Retention!)

Reading Time: 3 minutes

This post demonstrates a practical example where controlled folders in SharePoint have benefits not easily done with metadata. This use-case is for a Finance team who work with financial documents throughout the year requiring the documents be made Records once the fiscal month is over and the documents for the month are complete.

The easiest way to do this is with folders, however… I want to automate folder creation to guarantee a standard structure each fiscal year and to prevent end-users from “willy-nilly” creating the folders themselves. This was previously possible by the Send an HTTP request to SharePoint Flow action, but with the recent addition of the Create new folder action in Microsoft Flow, this just got a whole lot easier!

Here’s how the process works end-to-end. This is something that could be done for many teams, but particularly Finance since they often work on a time-period basis.

  1. Turn off folder creation at the library level in advanced settings. (You don’t want manual folders being created in the library)
  2. Configure a retention label to comply with your own retention requirements and ensure the Label is set to classify the document a record when the label is applied
    • Retention label settings
  3. Build a Microsoft Flow to run once at the start of each fiscal year. The Flow will automatically create a Fiscal year parent folder and 12 Fiscal year month sub-folders within it using the new Create new folder action. (Steps D,E)

The Flow to create the fiscal folders has 5 steps (steps A-C explained below):

Flow Steps All

Step A: This Flow will run once at the start of each fiscal year.

Step B: Initialize the Fiscal year string variable to be in this format: CCYY-YY where the current year is CCYY and next year is YY (Example: 2019-20):

Step B

the value is this formula:


Step C: Since we want to create a number of consistently-named subfolders, the best way to do this is by creating an array of folder names in an array variable, FiscalMonths:

Step C

Folders created!

In the TeamMonthlyProcesses document library, here’s the folders created for the current fiscal year once the flow runs! How convenient. 🙂

Fiscal folders created

What happens when the fiscal month documents are done?

Apply retention label to fiscal month folderThis is where having the documents in a folder as opposed to only having fiscal month and year as metadata really makes a difference… when the fiscal month is over and the documents within it complete, the retention label can be applied to the fiscal month folder. This will automatically propagate the label to all documents within it making them all records!

This can be done manually by setting the retention label on the folder (setting the retention label for the month of July is shown).


Here’s what happens when the retention label is applied to the folder:

Folder Record

Documents record

Alternatively, you can trigger this action in an automated way thru Microsoft Flow. Refer to my post, Setting a Retention Label in SharePoint from Microsoft Flow, for details on how to do this.

The choice of folders versus metadata is a complex one and there are numerous factors to consider. This post is a good example to demonstrate how folders can help with organizing documents and applying retention. With the new Microsoft Flow Create new folder action, it’s even easier to build out solutions like this!

Thanks for reading.


Credit: Photo by Andrew Pons on Unsplash


  1. I like this, simple, easy, elegant. I am thinking of doing something like this in my OneDrive with my Photos. The photos you take on your device(s) all get uploaded to one folder in OneDrive. I like my photos to be saved by year and month so I am going to see about writing a flow to move them around as they come in (And of course grab them from Google as well). Now to find time to do that.

  2. This is a great article. Unfortunately it exposed a weakness in SharePoint’s retention management in that when the folder comes up for disposition the user will get asked to the confirm the disposition individually for every file in it instead of one confirmation for the entire folder. Hopefully Microsoft will understand and address this at some point and permit retention labels to be truly applied to folders.

    1. Yes, although you can “bulk review” all documents in the folder at once. It does buy the flexibility if you had some documents you wanted to take a different disposition action on. Good to know… the folder will remain after disposition… it only affects files.

      1. JCK makes these points elegantly as always. I do, however, still lament SharePoint’s inability to apply disposition to a series (folder) rather than a document, especially when dealing with case folders when disposal of the folder itself is a benefit. I also have my reservations that users can apply disposition effectively at volume in the current mechanism. All this said maybe I’m too ‘fussy’?

  3. Great post, JCK! I agree that this does expose the lack of an aggregation mechanism in the overall retention approach that Microsoft has taken. While “bulk review” is the obvious work-around, the quantity of information to be process will quickly overwhelm a typical user’s ability to do anything in “bulk”.

    The great thing about JCK’s approach here is that it could be extended/re-purposed for things that have regimented structures and well understood structures.

  4. If the retention is a deletion policy based on creation date, is the deletion only applied to the documents in the folder individually or will the entire folder be deleted based on the date it was created?

    Also great blog, thank you, I love the information coming out at the moment, probably because of the amount of work I am (fighting) doing with the new retention features!

    1. Hi Colin,
      The Deletion policy will only ever delete the individual documents, not the folder. In your example, it would use the creation date of each document to determine when it should be deleted. (At the next weekly timer job, that is)

      The folders will remain.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.