Gateway Tag Change Script newValue help

I have a Gateway Tag Change Script in a project. (8.1.17)

I need to get the new value of the tag that changed. I have tried several things:

newValue.getValue().value
newValue.value
event.newValue.getValue().value
event.newValue.value

Can anyone help with the correct syntax?

According to the docs: Gateway Event Scripts | Ignition User Manual

you want

newValue.getValue()
2 Likes

It would be:

newValue.getValue()

or

newValue.value

Either will work, the second is more performant.

What leads you to believe that it isn't returning the correct value, or that this is the incorrect syntax?

I was getting an error about 'none' type, I believe. I've changed it so I'll have to wait until it triggers again to see the exact error.

Generally, this is due to not checking for initialChange.

if not initialChange and newValue:
    #your code here

Odd that the official syntax is currentValue on tag event scripts but newValue in gateway tag change scripts. To your original question, we use currentValue.value in our gateway tag change scripts and that has been working fine.

I have
"""
if not initialChange and newValue.value ==1:
"""

Just for kicks, try changing it to:

if not initialChange and currentValue.value == 1:

So, that should then be:

if not initialChange and newValue and newValue.value == 1:
  #your code

if newValue is none, then you will still get an error, so you should check that it is not none prior to using it.

How could it be none? It's a boolean tag. If it gets to the tag change script, then it can read the tag, right?

newValue isn't a boolean though, its a QualifiedValue, and it is completely possible that a None value is sent to the tag change. This is always the case on initialChange for the previousValue.

2 Likes

I'll try that and see if that works! Thank you

This is what worked:

if not initialChange and newValue.value:

1 Like