# How to check if a tag is part of a UDT or not?

**URL:** <https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 24, 2025, 2:46am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498 "2025-04-24T02:46:04Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [April 24, 2025, 2:46am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498/1 "2025-04-24T02:46:04Z")

</div>

Before I write something, is there a tag property I'm unaware of to flag if a tag is part of a UDT instance or not?

Basically, I have a script that pulls out the alarm info for all tags that have alarms from a given path, but I also want to know if the tags are within UDTs so that I can filter them out in Excel and then bulk configure the non-UDT ones. (However I still want the UDT tags in there as well)

I could run the tag.query function again setting `includeUdtMembers: False`, but then I'd be running it twice and then have to combine the results together... maybe not so bad for my use-case. It'd be nice for other uses though if there was a tag prop to read

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [April 24, 2025, 3:11am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498/2 "2025-04-24T03:11:32Z")

</div>

I’m curious as well. I ended up querying twice (perhaps even a third) for my need to ‘quickly’ get through a similar task - fully quantifying all types of historical tag configurations (of a base tag, within a base UDT definition, instance UDT w/ override, nested UDT instance within a UDT def - w/ override, etc.).

I imagine that this ‘controlling definition’ property (or equivalent argument as an input to a query) would be a very useful one.

---

<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:** [April 24, 2025, 3:22am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498/3 "2025-04-24T03:22:43Z")

</div>

I've got this at the moment. It's not _too_ bad..

```python
baseTagPath = '*'
provider = 'default'
query = {
    "options": {
      "includeUdtDefinitions": False
    },
    "condition": {
      "path": baseTagPath,
      "attributes": {
        "values": [
          "alarm"
        ],
        "requireAll": True
      }
    },
    "returnProperties": [
      "alarms"
    ]
}

# get the tags not in UDTs - the only reason we need this is to know which tags are NOT in UDTs
query['options']['includeUdtMembers'] = False
alarmTagDetails_NonUDT = system.tag.query(provider, query)
# get all tags, including those inside of UDTs
query['options']['includeUdtMembers'] = True
alarmTagDetails = system.tag.query(provider, query)

# add a flag to identify if the tag is in a UDT or not - initially set all to True, then update later
for item in alarmTagDetails:
	item['inUdt'] = True

# we need a map to link fullPaths to their list indices
fullPathIndexLookup = {item['fullPath']: i for i, item in enumerate(alarmTagDetails)}
for item in alarmTagDetails_NonUDT:
	# overwrite the "inUdt" flag to False
	alarmTagDetails[fullPathIndexLookup[item['fullPath']]]['inUdt'] = False

```

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 24, 2025, 4:25am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-tag-is-part-of-a-udt-or-not/105498/4 "2025-04-24T04:25:00Z")

</div>

In the DB the UUIDs are different, if that helps (you get f"{folder ID}.{tag ID}" for UDT members), but I'm not sure if you can pull out the UUID of tags from property
