# Trouble with gateway scripting

**URL:** <https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111>\
**Category:** Ignition\
**Created:** [June 26, 2019, 4:33pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111 "2019-06-26T16:33:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyg](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@andyg](https://forum.inductiveautomation.com/u/andyg)\
**Post date:** [June 26, 2019, 4:33pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111/1 "2019-06-26T16:33:02Z")

</div>

Hi, I am having some trouble with gateway scripting. I have some tag change events that are running through specific tags (Tag-\> Tag Events-\>Value Changed) that work perfectly. However, when I use the exact same code in the gateway scripting console ( Gateway Event Scripts → Tag Change ) it doesn’t execute when the specified tag changes value. Im not sure if there is a different way of scripting in the gateway console, or if there is something I am missing, but any help would be appreciated!

I have written a tester code, which works fine through tag events but does not execute at all in the gateway script:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c459ad904c1fe30b757859175ff12e325ceec2a7.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 26, 2019, 4:44pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111/2 "2019-06-26T16:44:16Z")

</div>

`[.]` means "use the tag provider local to this tag - it only works when you’re on an actual tag. Use `[~]` to refer to the _project’s_ default tag provider (note that this will _only_ work in gateway tag change scripts like this, and _will not_ work from tag event scripts. Or, omit all relative references and hardcode the provider: `[default]` (or whatever your realtime tag provider is actually named).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 26, 2019, 5:29pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111/3 "2019-06-26T17:29:53Z")

</div>

Gateway tag change event scripts have access to the tag path and related properties for the tag that changed–you can programmatically construct a tag path relative to that.

---

<div class="post-metadata">

**Author:** ![andyg](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@andyg](https://forum.inductiveautomation.com/u/andyg)\
**Post date:** [June 26, 2019, 5:45pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111/4 "2019-06-26T17:45:25Z")

</div>

Thank you very much! helped a lot.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 26, 2019, 5:51pm UTC](https://forum.inductiveautomation.com/t/trouble-with-gateway-scripting/26111/5 "2019-06-26T17:51:53Z")

</div>

Reference for @pturmel’s comment; since the UI gives you absolutely no indication you can do this:  
[https://docs.inductiveautomation.com/display/DOC80/Gateway+Event+Scripts#GatewayEventScripts-TagChangeObjects](https://docs.inductiveautomation.com/display/DOC80/Gateway+Event+Scripts#GatewayEventScripts-TagChangeObjects)
