Today I tried to copy a file using Microsoft Flow. I started with a When a file is created or modified in a folder trigger.

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 trigger

Then I thought that get file metadata would be a good step. So that I can filter on the metadata so that I can decide if/when I get Flow to copy the file.

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 getfilemetadata

Then I added a send an email  action in. So that I can ensure that my Id is set to the id of the item.

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 idavailable

Then I ran my flow by updating a document. This now triggers the flow but I got a bit of a surprise:

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 id

What is that Id? That is the Url to my document?

As the Get File properties action want the Id of the item this is quite annoying.

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 getfileproperties

It looks like getting to the document properties could be quite tricky.

So far the only way around this problem is use the Get Files (properties only) and then use an apply to each to step through all your documents in your library. Then it is possible to compare the file name with the filename that triggered the Flow in the first place. This of course is not a very nice solutions as Flow will slow down when you get more documents in your library.

So why is this so complicated?

Well it is all in the trigger. Rather than using the When a file is created or modified I should have used the trigger When a file is created or modified (properties only)

Manipulating Files in SharePoint with Microsoft Flow Microsoft Flow, Microsoft Office 365 whenfileiscreated

This trigger returns all the properties of the document. Easy mistake to make, but not easy to fix.

 

 

 

 

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

2 thoughts on “Manipulating Files in SharePoint with Microsoft Flow”

Leave a Reply

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