I am trying to insert data into a database based on a tag event script changing value, i am just trying to make it run a named query but the tag event script gives me an error saying project name is required in the gateway which i have already done.
Here is the error
Error executing script.
Traceback (most recent call last):
File "<tagevent:valueChanged>", line 2, in valueChanged
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:463)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:378)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Project name required for script execution: the Gateway Scripting Project is not set.
Hmm, it’s complaining that the “Gateway Scripting Project” is not set. You can find it under Config > System > Gateway Settings
in the Ignition Gateway.
https://docs.inductiveautomation.com/display/DOC81/Gateway+Settings
1 Like
Ah, this is actually a little more confusing.
Can you share your code? I don’t think you’re specifying the project correctly.
1 Like
This code or the query?
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
"""
Fired whenever the current value changes in value or quality.
Arguments:
tag: The source tag object. A read-only wrapper for obtaining tag
properties.
tagPath: The full path to the tag (String)
previousValue: The previous value. This is a "qualified value", so it
has value, quality, and timestamp properties.
currentValue: The current value. This is a "qualified value", so it has
value, quality, and timestamp properties.
initialChange: A boolean flag indicating whether this event is due to
the first execution or initial subscription.
missedEvents: A flag indicating that some events have been skipped due
to event overflow.
"""
system.db.runNamedQuery("UpdateTable")
You need to specify both a project and a path in your runNamedQuery
call.
1 Like
Thank you for the answer, could you please show me what that would look like?
system.db.runNamedQuery("MyProjectName", "path/to/my/NamedQuery")
Also, see system.db.runNamedQuery - Ignition User Manual 8.1 - Ignition Documentation and the "Gateway Scope Syntax" example.
1 Like
Sorry to bother you again but i still cant seem to make this work, ive tried to put in the path for the query but it still tells me its not found
This is the path to the query and ive tried with with and without the \query on the end
system.db.runNamedQuery("Dportv1", "C:\Program Files\Inductive Automation\Ignition\data\projects\Dportv1\ignition\named-query\UpdateTable\query" , {} )
The path/to/my/NamedQuery
is the folder and name as seen in the designer tree, not the file on the server’s filesystem. With forward slashes.
1 Like
Where can i find this path?
If you didn't make folders to organize your named queries, then supply just the query name.
1 Like
Thank you! this is the solution