Gateway Scripting Errors

I am having some trouble with 2 gateway scripts that I have made for exporting a table to a CSV file, and printing a trend. They are being triggered by a tag change event. Both scripts work when I plug them into the scripting playground, but when I try and use them as gateway scripts I get the following error:

Scripting.TagChangeScriptManager Error executing tag change script: Lakeland/PQ2

Traceback (most recent call last):
File “TagChangeScript:Lakeland/PQ2”, line 1, in
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute ‘nav’

at org.python.core.PyException.fillInStackTrace(
at java.lang.Throwable.<init>(
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(
at org.python.core.PyException.<init>(
at org.python.core.PyException.<init>(
at org.python.core.Py.AttributeError(
at org.python.core.PyObject.noAttributeError(
at org.python.core.PyObject.__getattr__(
at org.python.pycode._pyx37.f$0(<TagChangeScript:Lakeland/PQ2>:6)
at org.python.pycode._pyx37.call_function(<TagChangeScript:Lakeland/PQ2>)
at org.python.core.Py.runCode(
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(
at com.inductiveautomation.ignition.common.script.TagChangeScriptManager$TagChangeScriptHandler$
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

Here is a copy of the gateway scripts:

window = system.gui.getWindow(“Advanced/PQ_2”)
data = window.rootContainer.getComponent(“Table”).data
new = system.dataset.toCSV(data, 1, 0)
filename = “C:\PQ\PQ.CSV”
system.file.writeFile(filename, new)

window = system.gui.getWindow(“Advanced/PQ”)
label = window.rootContainer.getComponent(“Easy Chart”)
job = system.print.createPrintJob(label)
job.showPrintDialog = 0
job.fitToPage = 1
job.orientation = system.print.LANDSCAPE
job.showPageFormat = 0

What can I do to get these to work as Gateway scripts?


It looks like you are going to run into this problem because the Gateway Event Scripts are (for the most part) not user-interactive. I mean to say that they do not allow for opening windows and displaying or manipulating window components, such as with the system.gui functions.

Your best bet is to take the SQL script you have for your getComponent(“Table”).data and then use system.dataset.toDataSet to convert to the CSV file.

Let me know if I can help some more.

Here’s a brief example:

table = system.db.runQuery("SELECT * FROM Test")
ds = system.dataset.toDataSet(table)
new = system.dataset.toCSV(ds, 1, 0)
filename = "C:\PQ\PQ.CSV"
system.file.writeFile(filename, new)