AutoSave Report to database?

I would like to autosave a report to a database to be read back later from various clients.

This code works great but its save as a PDF on the gateway.

d=system.tag.read("Kiln1/StartUp/K1 ChargeNum")
path="StartUp_K1_",d.value
load=system.tag.read("Kiln1/History/SaveStartupK1")
if load.value == 1 :
	settings = {"path":"D:\KilnReports\K1", "fileName":path, "format":"pdf"}
	system.report.executeAndDistribute(path="StartUpK1", project="Kiln_control", action="save", actionSettings=settings)
	system.tag.write("Kiln1/History/SaveStartupK1",0)

I see 2 approaches to this. You could use system.report.executeReport instead of system.report.executeAndDistribute to retrieve a byte array then store this to the database as a blob. However, this will take up a good chunk of space in the DB and potentially cause performance issues. A better approach is to use system.report.executeAndDistribute to save the file in a centralized location, then store the path to the file in your database.

1 Like