In this post I will look at triggers in flows. As a regular follower of my posts you will have noticed the many posts about Power Automate.
Exciting Power Platform
I would like to put a quote form one of my customers here:
Excited is an understatement!
Yes, indeed Microsoft Flow is very exciting. When comparing with SharePoint Designer Microsoft Flow is 10.5 times better.
Not just the development of the Flows is a dream, debugging flows is so much easier. Running flows in Microsoft Flow is simply more stable that SharePoint Designer has ever been.
All the issues with running the flows that I have found have been with developer mistakes rather than problems with the product. I’m even getting close to the point where I would say that Microsoft Flow is a good competitor for Nintex and K2.
Do you want to give me a challenge and let me migrate your workflows?
Today I’m going to have a look at the triggers in Microsoft Flow that start a flow. I’m only going to have a look at the SharePoint triggers. It would be a mistake to go through all the 100s of triggers. in a single post.
Manual Trigger
I’m going to start with the manual trigger. So within SharePoint you want to get a user to start a flow manually.
So I created a flow called My important workflow and it appears within my menu when I select an item.
All you need is the trigger For a selected item. I already opened the advanced options that give you the options to ask for data from your user.
So in my case I’m getting Input, Email and File Content.
These input parameters in the trigger then become available as dynamic content within the flow.
You can create as many parameters as you need.
And you can even use choice options to restrict your input.
This all feels very easy to use.
When a file is created (properties only)
This trigger can be a bit confusing. Once you have completed the Library name the Folder will ask you for the same thing again. At least that is what it looks like:
So when you select a folder you can trigger the flow just by documents within a certain folder, but there is nothing there to stop you form configuring the folder within another library.
Most of the time however I would probably leave the folder blank anyway.
This trigger gives you all the properties of the document that triggered the flow. Title, Created, Created By and so on, even all your custom columns will appear.
When a file is created in a folder
When a file is created in a folder is another one of those confusing triggers.
You first supply the Site address then a folder within SharePoint. this can be a library or a folder in a library and then the option Infer Content Type. This means that the content type will be retrieved by Flow from the document.
Note that this trigger doesn’t give you the properties of the document. Using the file identifier ( the relative url of the document) it is possible to get the document properties later during the flow with an action.
When a file is created or modified (properties only)
The next trigger is very similar to the When a file is created in a folder however the result is very different.
The configuration options are the same, however the result is very different. This trigger you get the document properties back too.
Are you wishing for the option to have multiple triggers yet?
When a file is created or modified in a folder
Other than that this trigger also fires when files are modified there is no difference between When a file is created or modified in a folder and When a file is created in a folder
When an item is created
Now we get to the list item triggers.
No real exciting option here. You get all the properties of the item returned
When an item is created or modified
The final trigger handles modified items in lists as well.
Next posts in this series
Microsoft Flow – What SharePoint actions follow the triggers?
So now the big questions.
- How do you avoid triggering flows multiple times when you update a status field? Design your flow correctly!
- Can I trigger on things that aren’t SharePoint? Yes!
- Can you help me get started? Yes!
How do you avoid an infinite loop using the trigger When a file is created or modified (properties only) when you need to update the properties for a file while running this flow (e.g. in an approval flow)? ANy update would re-trigger the flow as it modifies the file properties …
you might want to have a look at the following post that I wrote: https://powerusers.microsoft.com/t5/Microsoft-Flow-Community-Blog/Develop-Flows-Like-a-Pro/ba-p/89890
So you would probably have to build in a safeguard so that multiple runs don’t run the same actions. So you could test at the start of your flow the value of a field in your triggering list item in SharePoint. Then within your flow update the list item to set the value of this safeguard field.
How could I create a flow that sends emails to specific users only when a specific file is modified in a SharePoint library?
Thanks
Create a flow with :
1. A trigger that fires on the modification of any document in the library
2. Add a condition that checks for the file name
3. Add a send an email to the yes branch of the condition and configure the specific user in the To field.
Thanks Pieter. I’ve tried but for some reason I can’t make it work. I’ve used these three option for the file name to be checked:
1.- Test file for Flow
2.- Test file for Flow.xlsx
3.- Test%20file%20for%20Flow.xlsx
And none of them seems to work as the file is modified but the email is not send. The condition indicates the expression result is false.
What am I doing wrong?
Hi Pieter, quick update. I manage to make it work.
1.- The trigger: when a file is created or modified (properties only)
2.- Condition: File name with Extension = Test for Flow.xlsx
3.- If yes – Send email To XYZ, Subject: File name with extension
4.- If no – do nothing
Cheers
Hi Peter, thank you for all the helpful information on your site.
There is a situation I am struggling with:
I have a document library with a custom Status column (new, under review, and approved).
I want an approval to trigger based on changes to the status column.
I created a flow:
1. When a file is created or modified (properties only)
2. Condition: check status value = review
3. If Yes, start approval and send email to Reviewer
Problem: the approval email is being sent when someone edits the file. I ONLY want the approval to run when the Status value is changed, NOT when file it self is modified.
Is there a way to do this?
Thank you!
S.
That is not an easy one. I created an idea for this on the community site so that we can get the values of the changed items. I could imagine spong this with two status fields.
1.current status
2. Previous status
Then in the flow check the combination. If they ate the same them you found a document update rather than a status update