# Way to trigger script based on new tags being added to tag provider?

**URL:** <https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446>\
**Category:** Ignition\
**Tags:** scripting, perspective, ignition81\
**Created:** [June 4, 2021, 5:24am UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446 "2021-06-04T05:24:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [June 4, 2021, 5:24am UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446/1 "2021-06-04T05:24:33Z")

</div>

Using the MQTT Engine which is able to dynamically create tags.

I have a script that parses the MQTT Engine tag provider and based on what is present, it builds out a Perspective view.

Is there a binding or trigger I can use for this script that is event-based when a new tag or folder is added / removed?

Right now, the script is just polling at some interval, but would like to move to an event-based script (don’t run it unless it’s needed).

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [September 15, 2021, 3:49pm UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446/2 "2021-09-15T15:49:01Z")

</div>

@wes0johnson Do you have any suggestions regarding a mechanism for triggering a script when MQTT Engine makes a structural change (adds/removes a node, device, or metric) and won’t trigger when the value of existing tags changes?

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [September 15, 2021, 8:25pm UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446/3 "2021-09-15T20:25:07Z")

</div>

Internally in MQTT Transmission we look for tags being added, moved, or deleted by using a TagStructureListener ([TagStructureListener](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.10/com/inductiveautomation/ignition/gateway/tags/model/TagStructureListener.html)) to detect these events. In turn we use this to control the ‘Refresh Required’ boolean tag. We could potentially use this in MQTT Engine to define a clearable tag - but this isn’t there today. I like the idea and will add it to our backlog.

For now, you can at least listen for new Edge Nodes in the [MQTT Engine]Engine Info/Edge Nodes folder. But, it seems you want more than just what this has to offer today.

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [September 16, 2021, 1:20pm UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446/4 "2021-09-16T13:20:02Z")

</div>

What is the max refresh rate of the tags within the [MQTT Engine]Engine Info/Edge Nodes folder?

Those tags will go a long way for what I’m looking for. Thinking of setting a Tag Change Gateway Event Script bound to a couple of those tags, but need to ensure my script is faster than the max refresh rate, otherwise I could tax the Ignition Gateway when there are a lot of nodes being added.

---

<div class="post-metadata">

**Author:** ![wes0johnson](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@wes0johnson](https://forum.inductiveautomation.com/u/wes0johnson)\
**Post date:** [September 16, 2021, 9:15pm UTC](https://forum.inductiveautomation.com/t/way-to-trigger-script-based-on-new-tags-being-added-to-tag-provider/47446/5 "2021-09-16T21:15:39Z")

</div>

The rate is really based on how quickly new Edge Nodes are coming in. It doesn’t run on a timer. If new NBIRTH messages are arriving and able to be processed quickly (i.e. don’t contain a lot of metrics) - this could update every couple of milliseconds. So, it could be quite fast…
