cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hugo93
Frequent Visitor

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 II
Resolver II

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,264)