Permission restriction using system.db.runPrepQuery in component event script

Hello,
I' m getting the error below due to this line in my component event script: result = system.db.runPrepQuery("SELECT DISTINCT id FROM Stoermeldungen_10713 WHERE t_stamp BETWEEN ? AND ?", [start, ende])

Traceback (most recent call last):
  File "<event:propertyChange>", line 23, in <module>
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepQuery(SELECT DISTINCT id FROM Stoermeldungen_10713 WHERE t_stamp BETWEEN ? AND ?, , [Mon Mar 11 06:00:00 CET 2024, Tue Mar 12 06:00:00 CET 2024], )

	caused by Exception: Error executing system.db.runPrepQuery(SELECT DISTINCT id FROM Stoermeldungen_10713 WHERE t_stamp BETWEEN ? AND ?, , [Mon Mar 11 06:00:00 CET 2024, Tue Mar 12 06:00:00 CET 2024], )
	caused by GatewayException: Error executing function 'RunQuery': The current user does not have the required roles for this operation.
	caused by GatewayFunctionException: The current user does not have the required roles for this operation.

Ignition v8.1.27 (b2023042509)
Java: Azul Systems, Inc. 11.0.18

I have an administrator permission and I don't encounter this problem when I use this function in the script console

Look in the Vision security section of your project properties. This would be Legacy DB access.

It looks like this:

1 Like

Are you logged into the designer (or Vision Client) with a user that has the Administrator role?

Yes

Look for typos, extra spaces. Also, log out and log back in if the role change was recent.

2 Likes

I finally let this field empty and it works now:

That would imply you were not logged in as administrator.

1 Like