cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hugo93
Helper I
Helper I

Trigger Approval flow only when 2 files created in a folder in channel

Hi everyone,

 

I am finding myself in front of an interesting challenge. I am trying to have an approval flow started when a document is created within a folder within a Team channel. To do so, I am using the Sharepoint Site Address and Library Name. The challenge I am finding myself in is that I want to be able to monitor all folders within this Library and only trigger a flow when 2 files are added within one of those folders. The use case is that we created channels in Teams for contractors so they can securely submit their invoices without anyone else accessing this specific channel. So at the end of every month, when the contractors add the two documents they need to provide within their channel, the approval flow would start and notify the right people.

 

How can I trigger the approval only when 2 files are created for the right contractor folder? 

If anyone has a suggestion or faced this challenge before, I am all ears! Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
iltoningui
Resolver IV
Resolver IV

Hi! @Hugo93 

You can take the following approach

1. Create a normal trigger for a file in the library

2. Get all files in same folder as the triggered file

3. Count if the number of files in the folder is 2

iltoningui_0-1642483550244.png

This approach will monitor one of the files then get all the files in the same folder.

iltoningui_1-1642483637916.png

iltoningui_2-1642483758876.png

condition

@{length(outputs('Get_files_(properties_only)')?['body/value'])}

this will test if the folder contains 2 files.

 

Are both file in the same format ie. both pdf?

View solution in original post

6 REPLIES 6
iltoningui
Resolver IV
Resolver IV

Hi! @Hugo93 

 

Are the 2 files related?

You can't have a trigger for two files, but in certain conditions you can have a trigger for one of the files

and check if the other one exists.

PowerAppsWizard
Resolver III
Resolver III

After the trigger, add a get items action with the specific folder filtered down. Then add a condition and count the fields returned from the get items and check if count is 2 (this is done with an expression and dynamic content). If yes start the approval else do nothing.

 

Screenshot_20220116-210904_Flow.jpg

Thank you for this suggestion. This could be a promising option. However, as I have many folders that I want to monitor, I can't pass the specific folder to the Get Items. Unless I was able to pass it as a variable? Any ideas?

Hi @iltoningui ,
Thank you for getting back to me. The two files are not linked, other than they should both be under the same folder. This is a bit challenging in that sense as I want to monitor a few folders and trigger the approval flow only when 2 documents are added in one of those folders (But they need to be added in the same folder)

iltoningui
Resolver IV
Resolver IV

Hi! @Hugo93 

You can take the following approach

1. Create a normal trigger for a file in the library

2. Get all files in same folder as the triggered file

3. Count if the number of files in the folder is 2

iltoningui_0-1642483550244.png

This approach will monitor one of the files then get all the files in the same folder.

iltoningui_1-1642483637916.png

iltoningui_2-1642483758876.png

condition

@{length(outputs('Get_files_(properties_only)')?['body/value'])}

this will test if the folder contains 2 files.

 

Are both file in the same format ie. both pdf?

Thank you @iltoningui , this is exactly what I was trying to achieve! 
Have a lovely day!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,882)