Question about Client Tag Change Script

Hello again, sorry about all my questions. I was trying to find a way to say, “When Tag A = Value A then run this named query”. I was thinking i could do this with a client tag change script, but i have not written any scripts like this. I am mostly familiar with SQL syntax, so most of this is foreign to me. I am using Ignition 8.0 if that makes a difference as well.


If the Tag Events are disabled, create a tag and then go back and modify script.

Maybe i don’t fully understand what you are asking me to do here. Can we just pretend that i have no clue as what you mean by “modify script”. Maybe there is a different/better way to do this as well. I am open to any suggestions out there.

My named query is literally just an insert statement, that adds one row with a timestamp each time. There are no parameters. When my message display tag.value = 3 then execute insert statement into sql table.

That second screenshot is accessed from the tag’s properties under the Tag Events section, if that helps?

I definitely use this method to insert log entries into a table on a trigger, so @kaushik.shah’s method is appropriate. However I would use this as the condition to stop entries being inserted when the tag is reloaded:
if currentValue.value == 1 and not initialChange: *Edited from ‘initialValue’
Considering you don’t need any parameters, just remove the parameter dictionary that kaushik.shah supplied in the function arguments.

An alternative would also be to do the same thing but use the gateway tag change event script area instead. It really depends on the circumstance: if my trigger tag is part of a udt, then I’ll use the tag’s change event handler; if it’s a standalone tag, I might use the gateway change event handler as it’s easier then to find your tag change scripts in the one place.

1 Like


1 Like

Here is what i have for the tag event script.

And my named query is this…

It does not appear to be working though. Did i make a mistake somewhere?

You can’t have an insert statement and a select statement in a single named query.

I don’t see why you need it. As your use case goes. Cause your script isn’t doing anything with data returned.

But, if you were, you’d have to make two named queries…

initalValue should be initialChange. Sorry, I was on my phone before I know I said initialValue. Also, what @wking said.
You can check any script errors once it’s executed by going into the tag properties and going to the Diagnostics tab (in v8) or right click on the tag and go to Diagnostics (v7). Check the Events section

This is what i am getting in the diagnostics tab for this tag.

Error executing script.
: Project name required for script execution: the Gateway Scripting Project is not set.

I tried

or does this mean something else?

Examples shown at the bottom of this link:

I tried both of those examples. That is what i was referencing when i tried this. Since i do not have parameters, those were the only two options i saw. I am still getting the same message though. I was reading about the gateway scripting, and was not sure if i needed to enter my project name in there. I am testing it now.

Now i am getting, the sql statement did not return a result set. Which it wouldn’t correct, since it is an insert statement.

*Note - it did still insert the row and information into the sql table though. Do i just ignore the current error and move on or should there be a step to fix it?

@dustin.corban Did you remove the select statement from the named query?..

Yes I did.


Did you select an update query from this dropdown?

1 Like

Nope. Sure didn’t. I thought that would just be used for an update query, not an insert. That fixed it. Thank you.

1 Like