Support for SharePoint Document Library Properties

In a blog post earlier this month, we announced read-write support for Person, Choice, and Lookup fields. This week, we’re pleased to announce another highly requested feature in the SharePoint connector – support for document library properties.

This support comes in the form of two new triggers – When a file is created (properties only) and When a file is created or modified (properties only) and three new actions – Get file properties, Get files (properties only) and Update file properties.

In this blog post, we’ll walk you through a detailed example of how to use these triggers and actions. We’ll also use this opportunity to introduce you to a couple of additional properties that have been added to ease your flow building experience.

File Triggers and Actions

Let’s suppose you have a document library for housing legal documents. In this library, you’ve added a Person column to track a document’s owner.

Let’s create a flow that will:

  • Notify the Chief Legal Officer and assign him/her as the owner whenever a new document is added.

  • Notify the owner whenever a document is modified

To do so, create a flow from blank and add the trigger – When a file is created or modified (properties only). Notice how this trigger contains a Library Name field which enumerates all the document libraries in your site.

Now add a Condition where you check whether the [Modified] property is equal to the [Created] property. If it is, then this is a new document. If it’s not, then it’s a modified document.

In the If yes branch (new document), add a Send email action. When you select the To field in the Dynamic content dialog, you’ll see all the fields in your document library including the Owner field which is further broken down into properties such as Owner DisplayName, Owner Email, Owner JobTitle, etc. Set the To field to the Chief Legal Officer, the Subject to “New document added – [Name],” and the Email Body to “[Link to Item].” Name and Link to Item are additional properties we’ve made available (more on this further down in the post).

After the Send email action, add the Update file properties action. This allows you to update the properties of a file. If you want to update the contents, use the Update file action. Match the Site Address and Library Name with the values entered in the trigger. Set the Id field to the [ID] of the uploaded file. For the Owner Claims field, select from the list of users or enter a custom value.

In the No branch (modified document), send an email to the Owner letting them know that a file they own has been modified and include a link to the item. In this case, we’re using the Owner Email field which is a property of the document library and the Name and Link to item properties.

Additional Properties

In this release, we’ve appended some new properties to triggers and actions to make SharePoint items easier to use in Flow and PowerApps. These properties are not direct visible in SharePoint. The full list is below:

  • Name – file name of the item in document libraries, display name of the item in lists

  • Folder path – Path to the folder the item is in, relative to the site address

  • Identifier – Value that can be used in file related actions for selecting a file

  • Link to item – Link that can be used to get to the file or list item. Only people with permissions to the item will be able to open the link.

Known issue

We are working on adding the item ID as an output of the Create File action, so that you can use it in conjunction with the Update file properties.

Onwards we go

The SharePoint + Flow story continues to be a high priority for us and we (can’t stop) won’t stop until we’ve ensured Flow is a worthy successor to SharePoint Designer workflows. As always, share your feedback using the comments below. If you have a question or an idea, head over to the Microsoft Flow Community.