# Trigger script Tag value change

**URL:** <https://forum.inductiveautomation.com/t/trigger-script-tag-value-change/25452>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [May 31, 2019, 7:07am UTC](https://forum.inductiveautomation.com/t/trigger-script-tag-value-change/25452 "2019-05-31T07:07:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel.kondol](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@pawel.kondol](https://forum.inductiveautomation.com/u/pawel.kondol)\
**Post date:** [May 31, 2019, 7:07am UTC](https://forum.inductiveautomation.com/t/trigger-script-tag-value-change/25452/1 "2019-05-31T07:07:52Z")

</div>

Hello,

I have script to generate xml file:

from xml.etree.ElementTree import ElementTree  
from xml.etree.ElementTree import Element  
import xml.etree.ElementTree as etree  
import xml.etree.cElementTree as ET

value1 = system.tag.read(“Torque/Torque\_IP033/LTR\_TIMESTAMP”).value  
value2 = system.tag.read(“Torque/Torque\_IP033/LTR\_TORQUE\_STATUS”).value  
value3 = system.tag.read(“Torque/Torque\_IP033/LTR\_TORQUE\_VALUE”).value  
root = ET.Element(“root”)  
doc = ET.SubElement(root, “doc”)

ET.SubElement(doc, “Date”, name=“Today”).text = str(value1)  
ET.SubElement(doc, “Torque”, name=“Status”).text = str(value2)  
ET.SubElement(doc, “Torque”, name=“Status”).text = str(value3)

tree = ET.ElementTree(root)  
tree.write(“C:\CSV\person4.xml”)

I would like to run this script every time the time stamp value change. I can run it on the button trigger but I would like this to be triggered always when tag value change regardless if client is opened or not.

Regads  
Pawel

---

<div class="post-metadata">

**Author:** ![accyroy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/accyroy/32/3386_2.png) [@accyroy](https://forum.inductiveautomation.com/u/accyroy)\
**Post date:** [May 31, 2019, 9:00am UTC](https://forum.inductiveautomation.com/t/trigger-script-tag-value-change/25452/2 "2019-05-31T09:00:39Z")

</div>

You can use Tag Event scripts for this. These run on the gateway, so will run whether the client is opened or not, but they can only write to a gateway accessible path.  
[https://www.inductiveuniversity.com/videos/tag-scripts/7.9](https://www.inductiveuniversity.com/videos/tag-scripts/7.9)

---

<div class="post-metadata">

**Author:** ![pawel.kondol](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@pawel.kondol](https://forum.inductiveautomation.com/u/pawel.kondol)\
**Post date:** [May 31, 2019, 10:48am UTC](https://forum.inductiveautomation.com/t/trigger-script-tag-value-change/25452/3 "2019-05-31T10:48:00Z")

</div>

Thanks accyroy.

Totally forgot Ignition Gateway is in different server, so my script did not work because Gateway has no access in to location I did pointed.

Thanks a lot again.  
Regards  
Pawel
