Something that SharePoint professionals occasionally get asked is whether it is possible to update a parent folder when child documents within it have been altered. Whilst my first response is to encourage the use of metadata and flatter file structures, it’s fair to assume that this isn’t always achievable. Some teams and personnel are comfortable with folders and don’t see a reason to change.
This blog post shows how you would achieve this using Documents Sets and SharePoint Designer. Document Sets are a bit more flexible than folders. As such this approach doesn’t lend itself well to existing folder structures: –
- Create a Site Column called DocSetName. Make it a Single line of text data type
- Create a LastModified column. Make it a Date/Time data type
- In the document library, where you want to make these changes, activate the management of content types via Document Library Settings à Advanced Settings à Content Types
- Click “Add from existing site content types” and add the Document Sets
- In the content type section, click on Document Set à Add from existing site or list columns and add DocSetName and LastModified
- Next (still within the Document Set Content Type Settings) click on Document Set Settings and scroll down to Shared Columns. Select DocSetName
- Next, within SharePoint Designer, create a new workflow at the document library level
- Set this workflow to automatically start when an item is created or changed. Using the Update List Item (update item in current list) action set the “LastModified” column to the current document item “Modified” column value. What this means is that any new document “Modified” column will be update the LastModified field of its parent Document Set.
- Back in your library, create a view that sorts by LastModified (descending) and you’ll see that the Document Set with the most recently edited item will be on top
There is one trade off to getting this working and it’s this. Any new items created within a Document Set MUST have the name of the Document Set manually entered into the DocSetName column. If this isn’t done than the workflow will error out. The reasoning behind this is explained below.
What does the workflow do?
This idea is that each Document Set shares the DocSetName column value with any document contained within it. As set up in step 3 any document that gets created or get modified will trigger the workflow. The workflow effectively goes to find the item whose “Name” column value is equal to current document item “DocSetName” column value. Subsequently it will always find the parent Document Set item and update its “LastModified” column with the current document modified date.
This means that each document set “LastModified” value is always going to be equal to the modified time of one of the child documents within it. Without the DocSetName column on the document level being manually filled, the workflow cannot make the association and will return an error.
That about covers it but let me know if you have any questions, suggestions and so on.