I've have a flow that filters current dates in an Excel column and then sends an e-mail with the filtered data. Except that it has a condition and when there are multiple rows with the current date it sends an e-mail for every filtered row data. Is there a way to prevent this, or a better solution?
Solved! Go to Solution.
Hello @dashiofhdfsdufs ,
in that case you can add a 'Condition' (so you'll still need one at the end) to check if the 'List rows...' action returned any values.
empty(<valueOutputFromListRows>) is equal to null
if it did, send the email, otherwise do nothing. It should look as the solution here.
Hello @dashiofhdfsdufs ,
it's because of the 'Apply to each'. If you're using the whole 'Body' output of the 'Filter array' in the 'Condition' then you shouldn't need the loop. Once you get rid of it it should send only a single email with the HTML table.
Have tried to change the condition but it still send an email multiple times. Added a terminate item but that didn't help.
The condition filters now on "formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-ddT00:00:00.000Z')". This works but does send multiple emails when conditions are correct.
Hello @dashiofhdfsdufs ,
you still have a loop in your flow, it loops through all the rows and for each row it runs the 'Condition'. And if any of the rows meets the condition it'll send the email.
Instead of looping through all the rows try to filter them right away in the 'List rows...' action and send the whole result in the email.
Or filter them in the 'Filter array' action and then use output of that 'Filter array' to create the HTML table and send the email.
That works, but now it sends an email even when there is no data to show.
Hello @dashiofhdfsdufs ,
in that case you can add a 'Condition' (so you'll still need one at the end) to check if the 'List rows...' action returned any values.
empty(<valueOutputFromListRows>) is equal to null
if it did, send the email, otherwise do nothing. It should look as the solution here.
Thanks for the solution, I've adjusted the condition on the select option if the value output is null, and this worked as well