# Add Tag change scripts

**URL:** <https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 4, 2022, 6:04am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821 "2022-03-04T06:04:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [March 4, 2022, 6:04am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/1 "2022-03-04T06:04:10Z")

</div>

I want to monitor some tags change, then do some scripts.  
if i have many tags want to monitor, I have to add many tag change scripts.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/b/3bdf57d61b1247f9a642406b97348443065557bc.png)

Is there another idea?

Today i find we can write scripts in tag or UDT tag.  
When its value changed ,we can write scripts.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e7ee8014c7b06bb03eec6fa4fbb481b6c0f0d9a9.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b4ab2749ef16dd1035799ad17ce4e57f250cd23a.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/13d9fe0f47d384d6d4f830572cc31df4407545f9.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d7605ca9d6c212919b11a078b33ced315733fb7b.png)

But has twoproblems:  
one : when PLC restart, it will write first? How I avoid it?  
Two: scripts can’t invoke gateway scripts ？How I invoke it？

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 4, 2022, 6:38am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/2 "2022-03-04T06:38:45Z")

</div>

You can monitor a lot of tags in one tag change script. This makes the most sense when they share similar functionality. Within the script you can check which tag triggered the execution and choose the appropriate logic–something like

```python
if "confirm_enable" in tagPath:
	# Do stuff
if "low" in tagPath:
	# Do other stuff
```

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 12, 2024, 7:56am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/3 "2024-06-12T07:56:33Z")

</div>

Problem One : solved by add script

```python
if not initialChange:
    # Do something useful here

```

Problem Two: tag change Scripts can't invoke ProjectLibrary also not solved?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 12, 2024, 8:12am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/4 "2024-06-12T08:12:39Z")

</div>

> [@taohongyu88](#):
>
> tag change Scripts can't invoke ProjectLibrary

**Use this:** [Ignition Docs | Gateway Scripting Project](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/project-library#gateway-scripting-project)

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 13, 2024, 9:03am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/5 "2024-06-13T09:03:18Z")

</div>

Yeah! one Project is OK.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/fe9b501d02c4f2932d0e75e797c79bf89ea97cd1.png)

But if I have two projects , they will use their each Project Library.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bb70c109090991c44a14f4df5c6792e3edf3280a.png)

This is worng.How to set?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/93515c7c071365ea9ca45fcfb0cd44a7cecfe050.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 13, 2024, 9:07am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/6 "2024-06-13T09:07:20Z")

</div>

Create a single project that the other two inherit, and put your scripting library there:  
[Ignition Docs | Project Inheritance](https://www.docs.inductiveautomation.com/docs/8.1/platform/projects/project-inheritance)

Templates and other universal resources should be put there as well, so they don't have to be maintained in multiple places.

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 13, 2024, 9:29am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/7 "2024-06-13T09:29:01Z")

</div>

Even thought in Project one , I set Script scope to All.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/4/a4aeb9ce4d86871701a6464369e115e6fb1be5cc.png)

But in Project two: I can't see or invoke the Script ?

I must to add a new Project add many public project Script .  
Then when I add new project , everyone set Inheritance?

---

<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 13, 2024, 11:26am UTC](https://forum.inductiveautomation.com/t/add-tag-change-scripts/56821/8 "2024-06-13T11:26:10Z")

</div>

Tags are gateway global resources. They do not belong to projects. There can be only one gateway scripting project. Your individual projects will have to share script resources in the one gateway scripting project.

Consider using gateway tag change events (defined in your projects) instead of tag valueChange events (defined on the tag). The former are part of a project, and therefore use that project's script library.
