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

Under the Flow Logic actions there is a "Set Flow Variables" step.

 

ElijahAromola_0-1684512063015.png

 

fbs
Giga Expert

Yes, that's helps.  But I still have 2 issues.  The test run is attached.

1. When I test, I see this: For Each Item in 1 - Look Up Records->SurveyDetail Records 1 of 1.  There are actually 7 records in the table.  And it looks like my code only does things for 1 record.  Why is that?

2. Assuming I can get the above issue working, how can I concatenate the variable values from record to record?  It looks like all I can do is set the variable, so even if I look at all the records, I would think I would only get the last issue.

Thanks

fbs
Giga Expert

I got rid of my first issue -- I had a condition hanging around so it only looked up 1 record.  But I still don't yet know how to solve the second issue.

You should be able to achieve this with inline scripting.

ElijahAromola_0-1684529103207.png

The script would be something like the above example but you would have to replace the " New Value" with whatever data you're trying to save.

Well, I am still having 2 issues. 

Issue 1: It doesn't seem like the For Each is iterating through all 6 records, though it indicates that it does.  From the execution, it looks like it's only doing one record, and it only looks like it's logging one record.  And it doesn't seem like the same record.  In the run, it says Set Flow Variables 1 and Log 1.  I thought it would do it 6 times.

 

Issue 2: In the Set Flow Variables step, I do: return fd_data.flow_var.issue += the value from the pill, which is For Each > SurveyDetailRecord > Issue.  Same for issueText.  For the body of the email, I use Flow Variables > IssueType and Flow Variables > IssueText.  But my email body comes out: 

return fd_data.flow_var.issueType += Medium

return fd_data.flow_var.issue += Power

 

Not sure what is going on.  Doc file attached.

Thanks