# EventScripts on a addTag Method

**URL:** <https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 19, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136 "2024-04-19T18:31:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [April 19, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136/1 "2024-04-19T18:31:58Z")

</div>

Gurus ,  
Can i create a tag with EventScript in attributes ? if yes may i know the right way please.

```python
            event_changed_script = [
				{
				  "eventid": "valueChanged",
				  "script": "\tif 1 \u003d\u003d 1:\n\t\tpass"
				}
			]
			system.tag.addTag(
				parentPath = parent_path,
				name = tag_name,
				tagType = tagType,
				dataType = dataType,
				attributes={
					"OPCServer":"Ignition OPC UA Server", 
					"OPCItemPath":"%s"%(OPCItemPath),
					"EventScripts" : event_changed_script
				}
			)

```

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 19, 2024, 6:44pm UTC](https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136/2 "2024-04-19T18:44:53Z")

</div>

Considering you appear to be trying to set change events on a large number of tags through scripting you are very likely going to bog down your tag system with those scripts.

Unless what you are planning to do in that event changed script will execute in single digit milliseconds or less, put the main driving logic in a project library script and use a [Gateway Tag Change event](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/gateway-event-scripts#tag-change-objects) instead. You can define a Gateway Tag Change Event to monitor multiple tags and use the same script.

What is the actual script that you plan on applying to those tags?

---

<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:** [April 19, 2024, 7:19pm UTC](https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136/3 "2024-04-19T19:19:08Z")

</div>

What Ryan said, but also,

- Use [system.tag.configure](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-configure), not the outdated `addTag` function.

- If you _do_ actually have a use case for repeating the same script on many tags, use the project library of your gateway scripting project to define repetitive scripts, so you only have to define the actual logic in one place (and can easily change it from there if needed).

---

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [April 19, 2024, 8:13pm UTC](https://forum.inductiveautomation.com/t/eventscripts-on-a-addtag-method/89136/4 "2024-04-19T20:13:03Z")

</div>

Thank you for the Right direction.

Gateway Events \>\> Tag Change is what i am going to use in my case,  
just wondering if i can create those tag changes dynamically through script ?
