# System.db.RunNamedQuery on Tag Value Changed Not Working

**URL:** <https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 11, 2023, 10:55pm UTC](https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370 "2023-10-11T22:55:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ly17](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Ly17](https://forum.inductiveautomation.com/u/Ly17)\
**Post date:** [October 11, 2023, 10:55pm UTC](https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370/1 "2023-10-11T22:55:25Z")

</div>

I have the following script in the "Value Changed" under Value Events for one of my tags and it doesn't work but works fine when I run it on the script console.

```auto
		parameters = {"Takt":RRvalue, "ProdLine":ProdLine, "ProdShift":"First"}							
		system.db.runNamedQuery("XYZ Lines Table Update", parameters)

```

How do I resolve this? Thanks.

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [October 11, 2023, 11:00pm UTC](https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370/2 "2023-10-11T23:00:24Z")

</div>

Tag event scripts run on the gateway and therefore have an extra required parameter: `project`

Look here under "Gateway Scope Syntax":  
[https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery](https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 11, 2023, 11:05pm UTC](https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370/3 "2023-10-11T23:05:27Z")

</div>

In addition to what @Matthew.gaitan said. Two notes:

1. The designer script console runs in designer scope (a variation of Vision Client Scope).
2. I would recommend putting this in a Gateway Tag Change Event, as query scripts of this type tend to have longer running times and many of them used in tag events will come back to bite you. Get in the habit of doing as little as possible in Tag Value Change events.

---

<div class="post-metadata">

**Author:** ![Ly17](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Ly17](https://forum.inductiveautomation.com/u/Ly17)\
**Post date:** [October 13, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/system-db-runnamedquery-on-tag-value-changed-not-working/80370/4 "2023-10-13T14:52:54Z")

</div>

Thanks for the help. Makes sense.
