System.db.RunNamedQuery on Tag Value Changed Not Working

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.

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

How do I resolve this? Thanks.

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

3 Likes

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.
5 Likes

Thanks for the help. Makes sense.