# Gateway Tag Change Script newValue help

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637>\
**Category:** Ignition\
**Created:** [June 10, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637 "2024-06-10T17:43:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 10, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/1 "2024-06-10T17:43:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 10, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/2 "2024-06-10T17:45:39Z")

</div>

According to the docs: [Gateway Event Scripts | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/gateway-event-scripts)

you want

```python
newValue.getValue()

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 10, 2024, 5:47pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/3 "2024-06-10T17:47:17Z")

</div>

It would be:

```python
newValue.getValue()

```

or

```python
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?

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 10, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/4 "2024-06-10T17:59:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 10, 2024, 6:10pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/5 "2024-06-10T18:10:54Z")

</div>

> [@bwhite](#):
>
> I was getting an error about 'none' type

Generally, this is due to not checking for initialChange.

```python
if not initialChange and newValue:
    #your code here

```

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [June 10, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/6 "2024-06-10T18:11:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 10, 2024, 6:15pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/7 "2024-06-10T18:15:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [June 10, 2024, 6:24pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/8 "2024-06-10T18:24:41Z")

</div>

Just for kicks, try changing it to:

```python
if not initialChange and currentValue.value == 1:

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 10, 2024, 6:29pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/9 "2024-06-10T18:29:06Z")

</div>

So, that should then be:

```python
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.

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 10, 2024, 6:40pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/10 "2024-06-10T18:40:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 10, 2024, 6:43pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/11 "2024-06-10T18:43:44Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 10, 2024, 6:46pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/12 "2024-06-10T18:46:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [June 12, 2024, 12:24pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-newvalue-help/91637/13 "2024-06-12T12:24:13Z")

</div>

This is what worked:

if not initialChange and newValue.value:
