Report Schedule if enabled from plc tag

I have reports that run at the end of each shift. I would like to only generate the report if the machine was actually run that shift. I have a tag set up in the plc to enable the report. Can someone point me in the correct direction. Thanks.

Pretty sure you won't be able to use the native report scheduler. Use a gateway scheduled script, that checks the appropriate tag, then uses if appropriate.


Phil's solution works but you can also just do it right in the report.
Instead of an Email action on the schedule, do a Script action and check for the tag being true. Then use the executeAndDistribute there to send the report or just pass.

This keeps the reporting schedule right in the report and not out on a tag change or timer.


Thanks, that worked great. I'm just researching a way to change the attached pdf's file name now.

That would be attachmentName in action settings of the call.

Doesn't this run the report twice (once on schedule and once for the executeAndDistribute call)? There's a good chance this is OK, but if the data collection steps are resource intensive it might become a problem.

To prevent the double-run (that I think happens), you can distribute the provided reportBytes using

No it does not cause it to execute twice.
This is why you use the Script action and NOT the email action.

I have run it on a test system and all looks good on a static report. I put the script in use on a live system and the report data is missing. It looks like the start and end dates are not being passed from the Parameters Tab. It looks like the executeAndDistribute is executing the report again w/o parameters.

It's executing again with the default parameters. These are whatever you set in the "Data" tab of the report builder. If you wanted to, you could override these parameters in the executeAndDistribute function by supplying a dictionary of parameter overrides (documentation), but I wouldn't recommend that.

Unless you're running an old version of Ignition, the report output (run using the parameters you specified in the scheduling tab) is already available in the context of the script you're writing. You access it through the reportBytes argument.

I recommend something like this:

if system.tag.readBlocking(['PATH_TO_TAG'])[0].value:

I didn't test this, so there might be a syntax or spelling mistake, but it gets the idea right.

Link to documentation.


Thanks, i was just building that right now. :grinning:

def handleFinishedReport(reportName, reportPath, dataMap, reportBytes):
	#see if the machine is in production
	PlcTagData = system.tag.readBlocking(["[default]BenchPAC_JeffOffice/Email_Machine_Active"])
	InProduction = PlcTagData[0].value
	if InProduction == 1:
		myServer ="ip"
		myFromAddr = ""
		mySubj = "Cooker Report Test"
		myBody = "See Attached."
		myHtml = False
		myToAddrList = ["sendTo"]