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

Only trigger flow if folder has files

Hi All,

 

Have written a flow which reads file names in a folder, adds them to a HTML table, which it embeds into a nicely formatted Email and then finally moves the files on to another folder.

Problem is, the flow runs when there are no files, sending a blank Email, which I know wont be an acceptable solution.

What can I add to the start of the flow so that the above only runs if the there are 1 or more files in the folder?  

 

P.s. the flow is triggered by a schedule.

Still very new to automate so all help appreciated.

Thanks - David.

2 ACCEPTED SOLUTIONS

Accepted Solutions
happyume
Solution Sage
Solution Sage

After your List Folder action, add a Condition, on the left part put expression:

length(outputs('List_folder')?['body'])

 

happyume_0-1627560299279.png

 

Your Filter Array and other actions for Sending Email will come under the Yes branch.

 

If I have answered your question, please mark your post as Solved.
If you like my responses, then please give it a Thumbs Up.

View solution in original post

DavyNix
Helper I
Helper I

For anybody reading this  - remember that you must also tell your flow not to count folders:

 

DavyNix_0-1627575003689.png

 

View solution in original post

6 REPLIES 6
happyume
Solution Sage
Solution Sage

Most likely you are listing files in a folder and then using Apply to Each to go through each file and get the filename.

 

Under such scenario (or if you have used a different method), all the files in a folder must be coming to you as an ARRAY.

 

You can use length(ARRAY_NAME) to get the number of files. At this point, use a Condition if length(ARRAY_NAME) > 0 then send email else don't send email

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi there,

 

Thanks for your reply....

 

So the condition would sit between list filter and filter array?

 

Could you give me a clue as to how this might look?  The learning curve for me is understanding the syntax for the expressions.

 

DavyNix_0-1627557923691.png

Many Thanks...

happyume
Solution Sage
Solution Sage

After your List Folder action, add a Condition, on the left part put expression:

length(outputs('List_folder')?['body'])

 

happyume_0-1627560299279.png

 

Your Filter Array and other actions for Sending Email will come under the Yes branch.

 

If I have answered your question, please mark your post as Solved.
If you like my responses, then please give it a Thumbs Up.

View solution in original post

DavyNix
Helper I
Helper I

 @happyume  - Perfect!  Thanks 🙂

DavyNix
Helper I
Helper I

For anybody reading this  - remember that you must also tell your flow not to count folders:

 

DavyNix_0-1627575003689.png

 

View solution in original post

DavyNix
Helper I
Helper I

@happyume  - I may have spoken too early!  All working well except the flow now sends an Email for each file in the folder.  The reason for building this flow was so that one summary Email (summarising the contents of the folder) was sent per day.  Is it "Apply to each 3" which is now causing this to send one Email per file?  If yes, do you have any ideas to stop it.  So close!

DavyNix_0-1627655533306.png

Thanks - David






Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,126)