Gateway Script

I have a script that runs fine as a client script, however when I try it as a Gateway script, it fails. I need to create a file and write data to it at a specific time. The data I am using are expression tags from [Client] tags group. Is this the problem?
Here is the info from the Gateway console error, I’ve also included the script I’m trying to run…

com.inductiveautomation.ignition.gateway.web.pages.config.systemconsole.LogViewer$SerializableLoggingEvent$ClonedThrowable: null
org.python.core.Py.NameError(Py.java)com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.getTagValue(AbstractTagUtilities.java:61)sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)java.lang.reflect.Method.invoke(Unknown Source)org.python.core.PyReflectedFunction.call(PyReflectedFunction.java)com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:310)org.python.core.PyObject.call(PyObject.java)org.python.core.PyObject.invoke(PyObject.java)org.python.pycode._pyx3.f$0(<TimerScript:Production File (60000) [Delay, Shared]>:12)org.python.pycode._pyx3.call_function(<TimerScript:Production File (60000) [Delay, Shared]>)org.python.core.PyTableCode.call(PyTableCode.java)org.python.core.PyCode.call(PyCode.java)org.python.core.Py.runCode(Py.java)com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:72)java.util.TimerThread.mainLoop(Unknown Source)java.util.TimerThread.run(Unknown Source)
com.inductiveautomation.ignition.gateway.web.pages.config.systemconsole.LogViewer$SerializableLoggingEvent$ClonedThrowable: null
org.python.core.Py.NameError(Py.java)com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.getTagValue(AbstractTagUtilities.java:61)sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)java.lang.reflect.Method.invoke(Unknown Source)org.python.core.PyReflectedFunction.call(PyReflectedFunction.java)com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:310)org.python.core.PyObject.call(PyObject.java)org.python.core.PyObject.invoke(PyObject.java)org.python.pycode._pyx3.f$0(<TimerScript:Production File (60000) [Delay, Shared]>:12)org.python.pycode._pyx3.call_function(<TimerScript:Production File (60000) [Delay, Shared]>)org.python.core.PyTableCode.call(PyTableCode.java)org.python.core.PyCode.call(PyCode.java)org.python.core.Py.runCode(Py.java)com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:72)java.util.TimerThread.mainLoop(Unknown Source)java.util.TimerThread.run(Unknown Source)
Gateway Script.txt (2.15 KB)

Yes the client tag is the problem. You cannot reference client tags in the gateway script since they are only available in the client.

I have more of a question than a problem.

Here is the background: I have a script that I’d like to run that changes line colours based on certain conditions, I’m thinking I’d only like to have this script execute when the line’s associated tag changes.

Now for my question: is it better to execute the tag change scripts at the client side or the gateway side? All of the tags that I’d be monitoring for change reside in the SQL database. I’d like to only have the script execute once rather than once per client.

I know I may have answered my own question but would like a more experienced opinion

Brian

If you only want the script to run in one place you would use a Gateway Event Script. The gateway event scripts run on the gateway in one location even if a client is not open. The client scripts run on every single client that is open and if no client is open nothing runs.

Unless I’m missing something big, I don’t know why you would use scripting at all. If you want to change a color based on a tag, simply bind the property using a tag binding. If you need something more complex, you could probably use an expression.

Again, I’m probably missing something, but overall, it’s easier to use binding rather than scripting when possible.

Regards,