# Gateway and Client scripts won't run when triggered

**URL:** <https://forum.inductiveautomation.com/t/gateway-and-client-scripts-wont-run-when-triggered/19569>\
**Category:** Ignition\
**Tags:** ignition78\
**Created:** [September 6, 2018, 8:49pm UTC](https://forum.inductiveautomation.com/t/gateway-and-client-scripts-wont-run-when-triggered/19569 "2018-09-06T20:49:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [September 6, 2018, 8:49pm UTC](https://forum.inductiveautomation.com/t/gateway-and-client-scripts-wont-run-when-triggered/19569/1 "2018-09-06T20:49:15Z")

</div>

I have tried to trigger a script from the Client and Gateway Scripts but they do not run and there are no errors reported when triggered. What am I missing? My trigger tag is listed on the tag page.

Downtime\_Reporting/TRG

Here is my script which should work.

trg = system.tag.read(“Downtime\_Reporting/TRG”).value

if trg == 1:  
system.tag.write(“Downtime\_Reporting/DT\_Location”,event.source.parent.getComponent(‘Drop Machine ID’).selectedLabel)   
system.tag.write(“Downtime\_Reporting/DT\_Reporter”,event.source.parent.getComponent(‘Drop Reporter’).selectedLabel)   
system.tag.write(“Downtime\_Reporting/DT\_Cause”,event.source.parent.getComponent(‘Drop Reason’).selectedLabel)   
system.tag.write(“Downtime\_Reporting/DT\_Description”,event.source.parent.getComponent(‘DT Description’).text)   
system.tag.write(“Downtime\_Reporting/DT\_Time”,event.source.parent.getComponent(‘DT Time’).intValue)   
system.tag.write(“Downtime\_Reporting/Save\_Data\_Trg”,1)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 7, 2018, 3:49pm UTC](https://forum.inductiveautomation.com/t/gateway-and-client-scripts-wont-run-when-triggered/19569/2 "2018-09-07T15:49:55Z")

</div>

Try using a system.gui.getWindow() in your client script.

[https://docs.inductiveautomation.com/display/DOC79/system.gui.getWindow](https://docs.inductiveautomation.com/display/DOC79/system.gui.getWindow)

---

<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:** [September 7, 2018, 4:03pm UTC](https://forum.inductiveautomation.com/t/gateway-and-client-scripts-wont-run-when-triggered/19569/3 "2018-09-07T16:03:13Z")

</div>

What kind of script? Tag Change? Those don’t have an event.source. What you are trying will only work in a client tag change, and only if you use getWindow() to retrieve the open window you wish to affect.  
Instead, consider binding the tags of interest to custom properties of the target window’s root container. Then you can use event.source in a propertyChange event. As a bonus, the scripts will only run when the target window is open.
