I have a single boolean tag which represents whether or not my filter is currently in backwash. Whenever this value changes I wish to record an appropriate message in my backwash log database table.
I’m trying to execute the following script whenever my tag changes value.
system.db.runUpdateQuery("INSERT INTO backwash_log(event) VALUES ('Filter x backwash started')")
This script appears to be correct. I’ve tested it in the script console, in client scripts, in Gateway scripts, in component scripting. All of them work correctly. Yet, if I paste this into my tag’s ‘Value Changed’ event script it fails to execute and the gear icon displays a small red x beside it. I’ve tried some of the other functions; runQuery, runPrepUpdate, runUpdateQuery. All seem to behave the same way.
I could probably work around the problem, but this is by far the most straightforward option and it should be possible. Does anyone know what I’m doing wrong here?
You probably failed to specify which database connection to use. Tag events are not in project scope, so there’s no default connection. You must include the database connection name in the function call.