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!
Solved! Go to Solution.
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
This approach will monitor one of the files then get all the files in the same folder.
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?
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.
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.
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)
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
This approach will monitor one of the files then get all the files in the same folder.
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!