Gateway and Client scripts won't run when triggered

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)

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

https://docs.inductiveautomation.com/display/DOC79/system.gui.getWindow

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.