Hello, I have attached an image of the workflow that I am currently working on. As shown by the highlighted filter tools, I am using the results of each output to configure a Table and Report Text tool to use in an email output. I need to account for the possibility of each of the filter outputs returning no results with some sort of message in the table like "No Results Found". Does anyone know the best method for this type of logic? Thanks in advance!
Solved! Go to Solution.
Do you have version 2023.1 or later? I would address this conditional behavior using Control Containers. This would enable you to go one way if data was there, and another if no data exists.
Hope that helps,
-Jay
Hi @taliatest!
You could add a separate data steam for this by using a Count Records tool after the T anchors of the highlighted filter tools, and then use another Filter tool for when the count = 0, after which you could write your message with a report text. Then you would need to add these streams back to your data sets before your Layout tool. That's just one way.
Or, another way would be to still use a Count Records and then Append that to your data stream (have the Count Records go into the Target anchor vs the Source anchor so that the tool won't error since Count Records should always produce a count even if there's not anything coming through the source). Now that you have your count in your data, you could dynamically write a message with a formula tool (if count = 0 then "bla bla bla" else "yada yada" endif) and then you can call that field in the Report Text tool. Just make sure in the Basic Table tool that you select group by on the message you created with the formula tool so that you can use it in subsequent Report Text tools.
@Erin Thank you! That seemed to work. Do you know if there is a way to not have the email send if records are blank for all sections?
Also a word of caution - the email tool sends an email for every record that feeds into it. So 200 records going in means 200 emails going out. Likewise, 0 records in means 0 records out. I once accidentally spammed my team with 2000 emails or something ridiculous. Don't learn the hard way like I did! To be safe, you can add a test tool to count the number of records and error if it's more than however many you're expecting (especially useful if you're only expecting 1 email). Another option here that's more dynamic is a sample tool. First 1 row and group by all pertinent fields. Just a suggestion.
@Erin This is so helpful! Thank you so much!
User | Count |
---|---|
60 | |
24 | |
24 | |
21 | |
21 |