-1

At first I'm new to "StackOverflow" and second I'm not a native english speaker... so hopefully I can express myself clearly.

I write values to a sql-database(it's working!). This database is used in an reportview in "Ignition Designer" by using a query. enter image description here As you can see, I've two parameters, "StartDate" and "EndDate". When I test this query with fixed values, for example "2025-03-10 00:00:00" for StartDate and "2025-03-11 00:00:00" for EndDate, I get the results as intended. In preview I see my table with the wanted values. Now I've created a "Gateway Event" "onTagChange" with the following script(everything written with "xxx" I changed to ensure data protection):

from com.inductiveautomation.ignition.common.script.message import Request
from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue
from com.inductiveautomation.ignition.common.model.values import QualityCode

import time
import datetime

# Path des Emailsende Tags
sendEmailFlagPath = "[Task_1000]xxx/xxx/xxx/bBoolscherMerker"
# Zeitspanne/ Sammelzeit ermitteln
#Start_Datum = datetime.now() - timedelta(days=1)
#End_Datum = datetime.now()
# Tags auf TRUE pruefen
sendEmailFlag = system.tag.readBlocking(["[Task_1000]xxx/xxx/xxx/bBoolscherMerker"])[0].value
# E-Mail-Inhalt generieren
report_path = "xxx_xxx_ReportTest"
dateiname = "xxx_xxx_24hReport.pdf"
*report_parameters = {"StartDatum": datetime.datetime(2025, 03, 10, 0, 0, 0),"EndDatum": datetime.datetime(2025, 03, 11, 0, 0, 0)}*
report_bytes = system.report.executeReport(path = report_path, parameters = report_parameters, fileType = "pdf")
#date_str = system.date.format(system.date.now(), "dd.MM.yyyy")
if sendEmailFlag :  # Überprüfen, ob das Flag True ist
    body = u"""
    Test Report
    """
    
    # E-Mail versenden
    system.net.sendEmail(
        smtpProfile= "xxx",  # Hier den SMTP-Server eintragen
        fromAddr="[email protected]", 
        to = "[email protected]",  # Durch Komma getrennte Liste
        subject = "Testreport",
        body = body,
        attachmentNames=[dateiname], 
        attachmentData=[report_bytes]
    )
    
    # Erfolg protokollieren
    system.util.getLogger("DailyEmail").info("E-Mail erfolgreich versendet: {system.date.now()}")
    
    time.sleep(1)  # 1 Sekunde warten
    # Email Sendeflagge wieder auf false setzen
    system.tag.writeBlocking([sendEmailFlagPath], [False])

Basically it is working (without the lines in italic, the reportparameters), with fixed values im my query I get an e-mail with an attached .pdf. But I want to be flexible, mostly every day the database is getting new entries and I want to autogenerate every 24h an report and I only want the database entries from the last 24h. So I need to pass the dateparameters to the reportview... here I'm stucked.

Maybe someone can guide my in the right direction. If I expressd myself not clearly pls ask. Thanks in advance!

I've tryed to attach reportparameters to: system.report.executeReport(path = report_path, parameters = report_parameters, fileType = "pdf") but it get me an empty table...

2
  • Couldn't those parameters be stored in tags that are read by the table itself? ...so the script would simply update the tags prior to generating the report. Commented Mar 17 at 3:34
  • Thx for your reply... sounds like this could work. I just don't know how to implement this. I'll give it a try!
    – Andy
    Commented Mar 17 at 5:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.