# ERROR(500): Error executing function 'RunQuery': The current user does not have the required roles for this operation

**URL:** <https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252>\
**Category:** Ignition\
**Created:** [September 5, 2017, 2:22pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252 "2017-09-05T14:22:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [September 5, 2017, 2:22pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/1 "2017-09-05T14:22:50Z")

</div>

Hi I get an error when I try to see the data from my db on runtime, but it works in the designer, this is the error.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a6a894d4c05146cc761e17f9a8a0cab56b89bcef.png) ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/756e7a50bf3288b0e1860bbb6c96dfab35c78d28.png)

```auto
	ERROR(500): Error executing function 'RunQuery': The current user does not have the required roles for this operation.
com.inductiveautomation.ignition.gateway.servlets.gateway.functions.GatewayFunctionException: The current user does not have the required roles for this operation.

at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:408)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85)

at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:837)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)

at org.eclipse.jetty.server.Server.handle(Server.java:518)

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)

at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)

at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)

at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)

at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)

at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)

at java.lang.Thread.run(Unknown Source)

```

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [September 5, 2017, 3:32pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/2 "2017-09-05T15:32:42Z")

</div>

Do you have security set on this table? Are you logged in as the same user in the runtime client?

---

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [September 5, 2017, 3:41pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/3 "2017-09-05T15:41:32Z")

</div>

I dont have security on the table, I reinstalled ignition and I get the error again. The user is default “admin” “password”.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 5, 2017, 3:44pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/4 "2017-09-05T15:44:54Z")

</div>

As of Ignition 7.9.4 there’s a new set of client scoped permissions that prevent even authenticated clients, by default, from changing anything on the gateway.

[https://docs.inductiveautomation.com/display/DOC79/Project+Properties#ProjectProperties-ClientPermissions](https://docs.inductiveautomation.com/display/DOC79/Project+Properties#ProjectProperties-ClientPermissions)

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [September 5, 2017, 5:35pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/5 "2017-09-05T17:35:17Z")

</div>

And the tl;dr here is that security is turned on by default for new projects.

---

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [September 5, 2017, 6:03pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/6 "2017-09-05T18:03:28Z")

</div>

Thanks, I turned on all the permissions and it works.

---

<div class="post-metadata">

**Author:** ![joe.hammond](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@joe.hammond](https://forum.inductiveautomation.com/u/joe.hammond)\
**Post date:** [March 25, 2020, 5:16pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/7 "2020-03-25T17:16:29Z")

</div>

Just to be more clear: In Designer Version 8, choose Project | Project Properties. Once open choose Permissions under Vision then check the box that says Legacy Databases.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b3261187e37be219aeb75e31768d626b2fb7340c.png)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 30, 2020, 8:19pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/8 "2020-06-30T20:19:49Z")

</div>

Just to clarify things a bit further for everyone…

[https://inductiveuniversity.com/video/client-permissions/7.9](https://inductiveuniversity.com/video/client-permissions/7.9)

This video explains client permissions which are disabled by default after version 7.9.4. Checking the box ‘Legacy Database Access’ allows client database access outside of named queries and transaction groups. You should try to only use named queries and transaction groups where possible for security reasons.

The biggest confusion is the videos aren’t made for version 8.0 in my opinion.

---

<div class="post-metadata">

**Author:** ![Michael\_Frantz](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Michael\_Frantz](https://forum.inductiveautomation.com/u/Michael_Frantz)\
**Post date:** [October 31, 2022, 10:40pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/9 "2022-10-31T22:40:20Z")

</div>

Legacy DB Access got it working immediately. TYVM!

---

<div class="post-metadata">

**Author:** ![Miguel\_Gomez1](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@Miguel\_Gomez1](https://forum.inductiveautomation.com/u/Miguel_Gomez1)\
**Post date:** [June 20, 2023, 5:03am UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/10 "2023-06-20T05:03:17Z")

</div>

Just thank you, I spend like 3 hours trying to solve this issue. 😃

---

<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:** [June 20, 2023, 11:24am UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/11 "2023-06-20T11:24:36Z")

</div>

Turning on Legacy DB access is not a **solution**. It is a **patch** that re-enables insecure behavior of your system. The **actual** solution is to use Named Queries.

---

<div class="post-metadata">

**Author:** ![Miguel\_Gomez1](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@Miguel\_Gomez1](https://forum.inductiveautomation.com/u/Miguel_Gomez1)\
**Post date:** [June 20, 2023, 3:08pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/12 "2023-06-20T15:08:43Z")

</div>

Well, thank you. I tried using Named Queries but the data of the database was not showed.

For example in the SQL part I wrote this  
SELECT date\_, volume\_  
FROM _mydb  
WHERE date_ BETWEEN '{Root Container.initialdate.text}' AND '{Root Container.finaldate.text}'

And it worked with the solution from Joe Hammond.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/f/1fdf696367fd5cb10bb1e1edd797f1ab6de3b116.png)

So I created the same query at Named queries and in the table properties I called in the SQL Named Query but nothing happened, there is no errors but the table is not showing anything. (I'm new in ignition 🙂 ) Do you know why is this happening?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 20, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/13 "2023-06-20T15:11:31Z")

</div>

If you left it as `{Root Container.initialdate.text}` then it will never work. What is the name of the parameters in your named query? You need to use those, and then refer with a colon prrefix, I would imagine something like `:initialDate`. Show your full named query and how you bind to the named query.

---

<div class="post-metadata">

**Author:** ![Miguel\_Gomez1](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@Miguel\_Gomez1](https://forum.inductiveautomation.com/u/Miguel_Gomez1)\
**Post date:** [June 20, 2023, 4:49pm UTC](https://forum.inductiveautomation.com/t/error-500-error-executing-function-runquery-the-current-user-does-not-have-the-required-roles-for-this-operation/15252/14 "2023-06-20T16:49:59Z")

</div>

Thank you! I did it like you said and It Works! I turned off the Legacy DB and everything worked nice.  
I called the Named Query that I configured and just put the values.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/738e573812d04dc085a17596308e788fee4f3cbd.png)

Thank you again!
