Flow Designer: how to send just one email based on a number of records

fbs
Giga Expert

I am very new to all of this. I want to use a flow to send email that has information from a number of database records. Currently I have a Look Up Records action and then a For Each action that sends an email based on some data in each record. So, this might send 10 emails. I don't really want to send the email until I have read a number of records (based on a condition -- maybe a value of 0 in a given field. So, what should I do in my For Each action instead of sending mail? Do I have some kind of a script that writes to a variable and then use the variable when I want to send mail? What is the best way to accomplish this? Thanks

1 ACCEPTED SOLUTION

fbs
Giga Expert

OK - I have figured this out.  The correct line for the script is:

return fd_data.flow_var.issuetext += fd_data._2__for_each.item.issue + ';'

Thanks

View solution in original post

12 REPLIES 12

Elijah Aromola
Mega Sage

Is the email content still based off individual data in the records? Or are you wanting to check data in the records, then at the end of it you may or may not send a single, generic email?

Kind of a combination of the two.  It is based on data in the records.  Here is the scenario:

Let's say there are 2 records, and that the fields I'm interested in are "status" (like Major or Minor) and "issue" (like Fire emergency or Power is out).  One record might have Major and Fire emergency in those fields, and another record might have Minor and Power is out.

What I want to do is when a certain type of record is added (like with an id == 0), that would trigger an email with a body like this:

 

Major Issue - Fire emergency

Minor issue - Power is out

 

So I don't want to send 2 emails, just 1.  I need some place, like a text variable, or something to store these statuses and issues for each record it looks up with an id > 0.  When the record with id of 0 is added, that will trigger the email.  How do I do that?  Thanks

 

There are flow variables, you could try storing the data you need in your variable(s) and then check the variable value(s) after the loop.

Yes, that's what I was thinking.  Not sure how to do that yet.  I have created 2 flow variables, but how do I populate them?  What action do I need to specify to populate them?