Gateway Event Script "system.dataset.toCSV"

Igntion 8.1.55

I have a script that works fine when run through a button or the script console, but when it is executed as a gateway event (tag change), it doesn't populate the data from the historian. The attachment only contains the time stamp, all other fields are blank.

Here is a short version of the script.

from org.python.core.util import StringUtil
import java.lang.Exception

strsDate = system.tag.readBlocking(["[default]Start_Date"])[0].value
streDate = system.tag.readBlocking(["[default]End_Date"])[0].value

strTime = system.tag.readBlocking(["[System]Gateway/CurrentDateTime"])[0].value
strReportDate = system.tag.readBlocking(["Reports/ReportDate"])[0].value

TagsPath = ["[]FIT-1506/EU","[]FIT-1506/Totalizer/Kscale""]
headers  = ["t_stamp","FIT1506_GPM","FIT1506_KTotal"]
data = system.tag.queryTagHistory(TagsPath,startDate=strsDate,endDate=streDate, intervalMinutes=15, returnSize=96,aggregationMode="Average",returnFormat='Wide',columnNames=headers)
csv = system.dataset.toCSV(data)
strSubject = "%s DPE Export" %(strReportDate)
strBody = ""
objAttachment = StringUtil.toBytes(csv)
strFileName = "%s_DPE_Export.csv" %(strReportDate)
system.net.sendEmail(smtp=smtp_server, fromAddr=smtp_user, subject=strSubject, body=strBody, html=0, to=recipients, attachmentNames = [strFileName],attachmentData=[objAttachment],username=smtp_user,password=smtp_pwd)
filePath = "C:\myReports\%s DPE Export.csv" %(strReportDate)
system.file.writeFile(filePath, csv)

Can you post a more exact reproduction of your script?
It's hard to confirm whether the issues with it are typos or real.

For instance,

Is there actually a tag provider name, or do your literal tag paths include [] as the provider name?

You're also missing a provider name here.

Thank you,

by adding the tag provider name the gateway event script works, still don't understand why it would work from a button but not the gateway event script. In previous version of igntion using [] it knew to use the default provider.

Once again thank you, tech support still working on the issue.

Tag event scripts (e.g. valueChanged) run outside of any project and thus require explicit qualification of various things.

Distinct from tag change scripts, which run on the gateway but within the "scope" of a single project:

In your use case, [~] should work, to refer to "the provider I'm currently in".