I found this code on the user manuel. but i want to save each report on the date when it’s saved, but i only can choose one name.
d = system.date.format(system.date.now(),"MM-dd-yyyy hh-mm-ss")
reportViewer.saveAsPDF(str('MyReport-'+d))
Great Thanks for the help!
Now i want to save it automatically when a bit is activeted.
under a spicial path so i tought to do it this whey but it gives errors.
What is the error? For starters you will need a colon at the end of line 1 and you will need to indent everything underneath. And if “Essen/Extruder Laminator/TEST/opslaan” is a tag then you will need to read the tag value.
It says nothing, but nothing is happening. so i don’t know what i do wrong.
Did you implement the changes I suggested? If so, can you post the new code?
yes i did the chances, this is the script that i have now.
i doesn’t give an error it just don’t save it
#Saves the file as a PDF to a user selected location.
#The file selection window defaults to a name of “Daily Report”
tagValue= “Essen/Extruder Laminator/Status/E_EL1_Einde afkapcyclus”
if tagValue != 0:
reportViewer = event.source.parent.getComponent(‘Report Viewer’)
d = system.date.format(system.date.now(),“MM-dd-yyyy”)
reportViewer.saveAsPDF(str('parameters '+d))
filepath = (“C:Gebruikers\jubstudent01\ignition”)
Where is the script executed? It needs to be executed from a GUI element (like a button) to work. you can’t execute it on a tag change f.e., as that doesn’t have access to the gui elements.
Next, there are some weird things about your code:
This will just store given string under the variable “tagValue”, not its value
tagValue= "Essen/Extruder Laminator/Status/E_EL1_Einde afkapcyclus"
to read a tag, you need to call a system
method:
tagValue = system.tag.read("Essen/Extruder Laminator/Status/E_EL1_Einde afkapcyclus").value
The filePath
you set is just a loose variable, you don’t seem to use it anywhere. Besides, it uses backslashes, which are escape characters in Python (f.e. \n
means newline). You should either escape your backslashes \\
or use forward slashes (Python should translate it correctly to backslashes for Windows).
When I fix those things, the rest of the code seems to work.
it still doesn’t save the file. is the filepath needed to be linked to the server or is it also possible to save it at your PC