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 Specialist
Solution Specialist

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 Specialist
Solution Specialist

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 Specialist
Solution Specialist

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,429)