# Gateway tag change script

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301>\
**Category:** Ignition\
**Created:** [April 16, 2012, 11:04pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301 "2012-04-16T23:04:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luke](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@luke](https://forum.inductiveautomation.com/u/luke)\
**Post date:** [April 16, 2012, 11:04pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/1 "2012-04-16T23:04:13Z")

</div>

So if a Gateway tag change script is watching a db tag called Data/test1

using the following sript-

if newValue.getQuality().isGood() and newValue()!="":  
system.tag.writeToTag(“Data/test2”,newValue.value)

it won’t work if Data/test1 contains an expression. Data/test2 wil never update. Remove the expression (if test1 is just a value) and it works. Why is this?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 17, 2012, 12:28am UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/2 "2012-04-17T00:28:57Z")

</div>

What version of Ignition do you have? This worked just fine for me in 7.4.1:[code]value = newValue.value  
quality = newValue.quality  
isGood = quality.isGood()

if isGood and value != “”:  
system.tag.writeToTag(“Test2”, value)[/code]Assuming both tags are strings.

---

<div class="post-metadata">

**Author:** ![luke](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@luke](https://forum.inductiveautomation.com/u/luke)\
**Post date:** [April 17, 2012, 2:30pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/3 "2012-04-17T14:30:08Z")

</div>

We have 7.2.8

Both tags are strings and it does the same thing when using your code (won’t update).

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 17, 2012, 3:19pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/4 "2012-04-17T15:19:51Z")

</div>

Does it work if you remove the if statement?

---

<div class="post-metadata">

**Author:** ![luke](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@luke](https://forum.inductiveautomation.com/u/luke)\
**Post date:** [April 17, 2012, 4:18pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/5 "2012-04-17T16:18:38Z")

</div>

Still doesn’t work with the if statement removed.

---

<div class="post-metadata">

**Author:** ![luke](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@luke](https://forum.inductiveautomation.com/u/luke)\
**Post date:** [April 17, 2012, 5:06pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/6 "2012-04-17T17:06:02Z")

</div>

Ok, so I created a duplicate gateway tag change script and now it works. I hadn’t moved any folders or tag paths previously, and had even tried deleting the tag path from the original script and dragging it in “fresh”.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 17, 2012, 7:55pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script/4301/7 "2012-04-17T19:55:01Z")

</div>

So, your previous code does work right. It was just a matter of the script not firing? Is it all OK now?
