Hello, I've seen a few questions about how to only generate an output file if there are records. I have a similar problem but those answers aren't applying to my issue. I only want to render a report or generate a table if I have records present. Eventually I'll be sending an email out, so I don't want the email to go out with a blank report. Only if there are records in it... any help would be much appreciated. Thank you!
Solved! Go to Solution.
Hi Nathan! Thanks so much for the response and blog post. I looked it over and found it super easy to follow. However, I tried and I'm still not getting the desired effect- it renders the report regardless of how many records I have present (0, 4, 20). I just don't want a blank report being rendered, and thus sent out via email.
Any idea what I'm doing wrong here?
Hey @JGHOLLAND - I forgot that I'd come across this issue before and myself along with a couple of other colleagues couldn't find a solution with Control Containers not behaving as expected. We ended up doing what @OTrieger suggested iirc.
@DataNath - I'm not following the screenshots and how they say to connect things. Do you think you could *please* help flesh out his suggestion with an example workflow?
bump
Hi @JGHOLLAND , did you ever find a solution for this?
I am running into the same problem. I want the output generated into two different file types; an excel file and a pdf file. I want NO file being output at all if there are no records, so the same as you if I am not mistaken.
For the excel output I found the solution: in case there are no records I deliberately corrupt the file path so that no excel file is generated.
However, with the pdf file I cannot do the same, so when there are no records there is still a pdf file being generated.
(the solution from @OTrieger I could not figure out either, since the screen prints were not legible and from his explanation alone I could not figure it out)
okay, good to know that solution as well if your final step is to send the data by mail. Thnks.
But unfortunately in this case that does not work for me. I "simply" want a pdf file to be created when there are records of data and no pdf generated (also no blanc file) when there are no records, but so far it seems that when the render tool is used it ALWAYS creates an output, blanc or populated.
@JGHOLLAND I am happy to say that I finally found a solution, in a place I never truly looked well enough before.
The solution lies in the Render Tool itself, but for me in a kind of hidden place, because I always wanted one single report to be generated, or no report at all if there were no records. This is why I never dove into the "Group Data Into Separate Reports" options of the Render Tool, but there lies the solution nonetheless.
First I started of with a Count Records tool of course, followed by a select tool to turn the number into a string so that the following Formula tool could process it.
Then in that Formula tool I made a column with a condition that in case the value form the Count Records was zero.. otherwise if the value is NOT zero then a valid file path and file name is mentioned. When the value of the count records is indeed zero then you can make up any bogus file path.
Then use a join multiple tool to add this to your data and in your Render tool, make sure to "Field to Group on" your column created in your formula tool (Since I have only 1 value in that column only one output is always generated, so it gets always grouped into 1 output file).
But the most crucial part is the last option in the "Render Configuration": "Replacing Entire Path With Group", this replaces the filepath to a valid path in case there are records, but runs into a corrupt filepath if no records and no pdf file is generated, based on your formula tool.
Really happy with this :-)