Saving my report as a PDF with in the name : reportename + date hour now

Hi everybody,

I am actually want to add to my report PDF name, the date to be like "reportname_20230531_1107AM" (name_date_hour) if it's in an other format it's okay too !

I used a script on a TAG to trigger the function system.report.executeAndDistribute()

Actually this is my code :

if currentValue.value and system.tag.getTagValue("[Beadmill]rptType.value") == 0 :
settings = {"path":"C:\Reports", "fileName" : "test" , "format":"pdf"}
system.report.executeAndDistribute(path="SIP_SEAL", project="BeadMill_PVMC", action="save", actionSettings=settings)

and its working, by returning me my PDF file : "test"

i found on an other topic that if i change "fileName" by "filename" the name of the pdf file is "5-31-23 10AM"

I also tried this code but it doesnt work :
timestamp = system.date.format(system.date.now(), "ddMMMyy_HH:mm:ss")
fileName = "Beadmill_report_PH_Mill_" + timestamp + ".pdf"
settings = {"path":"C:\Reports", "fileName": fileName, "format":"pdf"}
system.report.executeAndDistribute(path="PH_Mill", project="BeadMill_PVMC", action="save", actionSettings=settings)

It seem like in a script with "system.report.executeAndDistribute" you cant call a variable ..

Does anyone have an idea of how to do it ?

Thank you for your help :smiley:

Try removing the colons ':' from the date.format function.

system.date.format(system.date.now(), "ddMMMyy_HHmmss")

2 Likes

Thank you Kyler ! It works :slight_smile: