# \[Help\] Tag Event Scripting error

**URL:** <https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927>\
**Category:** Ignition\
**Created:** [April 1, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927 "2022-04-01T12:51:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/1 "2022-04-01T12:51:25Z")

</div>

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

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 1, 2022, 12:52pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/2 "2022-04-01T12:52:47Z")

</div>

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](https://docs.inductiveautomation.com/display/DOC81/Gateway+Settings)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 1, 2022, 12:55pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/3 "2022-04-01T12:55:07Z")

</div>

Ah, this is actually a little more confusing.

Can you share your code? I don’t think you’re specifying the project correctly.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 12:56pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/4 "2022-04-01T12:56:56Z")

</div>

This code or the query?

```auto
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")

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 1, 2022, 1:01pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/5 "2022-04-01T13:01:15Z")

</div>

You need to specify both a project and a path in your `runNamedQuery` call.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 1:07pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/6 "2022-04-01T13:07:43Z")

</div>

Thank you for the answer, could you please show me what that would look like?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 1, 2022, 1:09pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/7 "2022-04-01T13:09:22Z")

</div>

> [@Dean\_Walsh](#):
>
> `system.db.runNamedQuery("UpdateTable")`

```auto
system.db.runNamedQuery("MyProjectName", "path/to/my/NamedQuery")

```

Also, see [system.db.runNamedQuery - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery) and the "Gateway Scope Syntax" example.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/8 "2022-04-01T13:36:14Z")

</div>

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

```auto
system.db.runNamedQuery("Dportv1", "C:\Program Files\Inductive Automation\Ignition\data\projects\Dportv1\ignition\named-query\UpdateTable\query" , {} )

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 1, 2022, 1:37pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/9 "2022-04-01T13:37:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 1:39pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/10 "2022-04-01T13:39:46Z")

</div>

Where can i find this path?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 1, 2022, 1:42pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/11 "2022-04-01T13:42:52Z")

</div>

> [@pturmel](#):
>
> the folder and name as seen in the designer tree

If you didn't make folders to organize your named queries, then supply just the query name.

---

<div class="post-metadata">

**Author:** ![Dean\_Walsh](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dean\_Walsh](https://forum.inductiveautomation.com/u/Dean_Walsh)\
**Post date:** [April 1, 2022, 1:45pm UTC](https://forum.inductiveautomation.com/t/help-tag-event-scripting-error/57927/12 "2022-04-01T13:45:03Z")

</div>

Thank you! this is the solution
