# Can a Tag Change scripts be triggered by a UDT/template (not sub-tag changes)?

**URL:** <https://forum.inductiveautomation.com/t/can-a-tag-change-scripts-be-triggered-by-a-udt-template-not-sub-tag-changes/40348>\
**Category:** Ignition\
**Created:** [November 5, 2020, 4:08pm UTC](https://forum.inductiveautomation.com/t/can-a-tag-change-scripts-be-triggered-by-a-udt-template-not-sub-tag-changes/40348 "2020-11-05T16:08:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aamrc](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aamrc](https://forum.inductiveautomation.com/u/aamrc)\
**Post date:** [November 5, 2020, 4:08pm UTC](https://forum.inductiveautomation.com/t/can-a-tag-change-scripts-be-triggered-by-a-udt-template-not-sub-tag-changes/40348/1 "2020-11-05T16:08:41Z")

</div>

Hi,

My Tag Change scrips are not triggering when I look for a whole UDT/Template change.

I’m using UDTs to group a set of tags together that would be always updated together.  
I’m also using scripting based on Tag Change.  
I subscribe to all tag changes with `path` as `[MQTT Engine]*`

My issue is that my Tag Change event script is not triggered at the Template/UDT level:  
`[MQTT Engine]Edge Nodes/group/node/dev1/my_udt`

My script is triggered at the sub-tags value change level:  
`[MQTT Engine]Edge Nodes/group/node/dev1/my_udt/speed1`

The following is a Sparkplug message I pubish, all the sub-tags are updated as a group under `value.mertics`. I’m hoping to start my script based on all the metrics arriving.

```auto
{
   "timestamp":1604591089193,
   "metrics":[
      {
         "name":"my_udt",
         "type":"template",
         "value":{
            "metrics":[
               {
                  "name":"speed1",
                  "value":"542",
                  "type":"string",
                  "timestamp":1604591089193
               },
               {
                  "name":"speed2",
                  "value":"testnode",
                  "type":"string"
               }
            ]
         },
         "timestamp":1604591089192
      }
   ]
}

```

Is it possible to detect a value change of a UDT? Or do I need to detect a sub-tag change and then interogate each or the other tag values independantly?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 5, 2020, 8:26pm UTC](https://forum.inductiveautomation.com/t/can-a-tag-change-scripts-be-triggered-by-a-udt-template-not-sub-tag-changes/40348/2 "2020-11-05T20:26:44Z")

</div>

I don’t believe you can detect a change in the UDT instance tag values as a whole; you can only detect single tag value changes.  
Even if you could, this would fire whenever any of its tags changed, not when they’ve all changed, which I think is what you’re after?  
You can read the timestamp of when a tag value has last changed, so you should be able to use that with each individual tag changed script to determine if all tags have updated or not, and when the last tag to update changes value, then run the rest of your script.

---

<div class="post-metadata">

**Author:** ![aamrc](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@aamrc](https://forum.inductiveautomation.com/u/aamrc)\
**Post date:** [November 6, 2020, 8:33am UTC](https://forum.inductiveautomation.com/t/can-a-tag-change-scripts-be-triggered-by-a-udt-template-not-sub-tag-changes/40348/3 "2020-11-06T08:33:25Z")

</div>

> [@nminchin](#):
>
> ead the timestamp of when a tag value has last changed, so you should be able to use that with each individual tag changed script to determine if all tags have updated or not, and when the last tag to update changes value, then run the rest of your s

Thanks for clarifying Nick, that makes sense.
