# Named queries not found from gateway scripts

**URL:** <https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457>\
**Category:** Ignition\
**Created:** [August 29, 2018, 7:38pm UTC](https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457 "2018-08-29T19:38:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick.garceau](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@patrick.garceau](https://forum.inductiveautomation.com/u/patrick.garceau)\
**Post date:** [August 29, 2018, 7:38pm UTC](https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457/1 "2018-08-29T19:38:19Z")

</div>

named queries not found from gateway scripts

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 1, in File “”, line 56, in getMissingMinutes at com.inductiveautomation.ignition.gateway.project.ProjectManagerImpl.executeNamedQuery(ProjectManagerImpl.java:2162) at com.inductiveautomation.ignition.gateway.db.namedquery.NamedQueryGatewayRpc.execute(NamedQueryGatewayRpc.java:25) at com.inductiveautomation.ignition.gateway.db.namedquery.NamedQueryGatewayRpc.execute(NamedQueryGatewayRpc.java:15) at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:346) at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.Exception: java.lang.Exception: Project “MissingMinutes” not found.

So this is working from the Tools/Script Console  
But from a Gatway Event Script, not at all.

What would be the reason for that one?

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [August 29, 2018, 8:05pm UTC](https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457/2 "2018-08-29T20:05:53Z")

</div>

If you execute from gateway scope you need to include the project name:  
[https://docs.inductiveautomation.com/display/DOC79/system.db.runNamedQuery](https://docs.inductiveautomation.com/display/DOC79/system.db.runNamedQuery)

---

<div class="post-metadata">

**Author:** ![patrick.garceau](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@patrick.garceau](https://forum.inductiveautomation.com/u/patrick.garceau)\
**Post date:** [August 30, 2018, 5:07pm UTC](https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457/3 "2018-08-30T17:07:46Z")

</div>

This is already what I am doing

```
	namedQuery = "MissingHours"
	parameters = {"siteName":siteName,"startDate":lastCheck}
	table = system.db.runNamedQuery("Axium",namedQuery, parameters)

```

Maybe I need a folder name for the Query name?  
Not sure what that would be?

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [August 30, 2018, 5:30pm UTC](https://forum.inductiveautomation.com/t/named-queries-not-found-from-gateway-scripts/19457/4 "2018-08-30T17:30:08Z")

</div>

This is for a named query called MissingHours. Are you trying to execute a named query called MissingMinutes somewhere else, perhaps line 56 of a script called getMissingMinutes? Post that part instead.
