Avoid sending Empty reports

Hey guys,
Just wanted to know if if there is a way to set up the reporting not to execute if there is not data in the report directly from the report.

just to be clear, I want to know if I can get this done through reporting module, I think there is a workaround if I want to go through scripting and that’s running the query and if the result is zero then don’t trigger the report using system.report.executeReport but if there is data in the result the execute the report.

That is exactly how we do it.
We do it on a scripted schedule, run a query, if data is returned then execute the report.

I mean at least there is a workaround which is good.
I really think this will be a great addition to the reporting module!

Try adding a script data source to your report that simply throws an exception if the query in question has no rows. I suspect that will prevent delivery.

That is some out of the box thinking. I like that!!! :sunglasses::+1:

I took a little different approach to this problem; might work for you, might not. I have a scripted data source for one of my reports. The script does some calculations on a dataset that the report pulls from ignition and looks for a few different types of warning conditions on equipment (mostly comparing to either set limits, or historical data [looking for shifts in baseline performance]). As the script runs its checks, if it finds a warning condition, it increments a counter. At the end of the script, this counter is published as a data source, like so:

data['totalWarnings'] = totalWarnings

The rest of the report is setup to present warnings in a human-readable format.

Then, for the Report Schedule, I have a Run Script action, instead of a Email action. The script looks like this:

	if dataMap['totalWarnings'] > 0:
		body = "Attached is the daily Furnace Idle Warnings report."
		recipients = ["user@example.com"]
		fileNames =['Furnace Idle Report.pdf']
		fileBytes = [reportBytes]
		system.net.sendEmail(smtpProfile='Default', fromAddr="ignition@example.com", subject="Furnace Idle Warnings", body=body, to=recipients, attachmentNames=fileNames, attachmentData=fileBytes)

If there were any warnings calculated by the script, the counter would be greater than 0, and it sends the report. If not, nothing happens. The script could be looking at any data source the report generates. I just created a counter in my script and published it as it made things simple, but you could just as easily look at the contents of an actual data source being used by the report with real data in it.

It’s not as user friendly to do things like adjust who gets the report, but it works for my needs.