# Dynamically disable a folder of tags in a UDT

**URL:** <https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443>\
**Category:** Ignition\
**Created:** [April 14, 2022, 12:32am UTC](https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443 "2022-04-14T00:32:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 14, 2022, 12:32am UTC](https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443/1 "2022-04-14T00:32:08Z")

</div>

I have a UDT that I use to monitor Allen-Bradley Logix PLC’s, and display status information on a diagnostics page. Within this UDT, I have a folder called “Clock”, which relates to a timekeeping AOI within the PLC. In every PLC I have access to, I add this AOI so that I have a common timekeeping structure.

But there are some PLC’s I don’t have access to, so those ones don’t have the Clock AOI. Ideally, I’d like to disable (or remove entirely) all the tags in the Clock folder if I don’t specify a path to the Clock AOI within the PLC. I can easily create an expression that returns `true` or `false` based on the presence or absence of that AOI, but I want a nice neat way of handling the tags in the clock folder so I don’t have them repeatedly trying to poll an address that will never exist.

I’ve considered binding the enable for each tag in the clock folder to something, but:

- You can’t use an expression binding on the enable property
- You can’t use a tag binding on the enable property
- You CAN bind to a UDT parameter, but the enable parameter is a boolean, and you can’t create boolean UDT parameters  
I’ve considered having two UDT’s, one with the Clock folder and one without, but I’d prefer to do this all in the one UDT if I can.

I’ve considered having the PLC and the Clock be separate UDT’s, and just putting either one or both in an instance folder according to whether or not they have the AOI, but that leads to more complexity in managing the different instances and linking information between the two UDT’s.

Any other creative ideas?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 14, 2022, 12:45am UTC](https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443/2 "2022-04-14T00:45:42Z")

</div>

My UDT knowledge is weak, but could you use `system.tag.configure` for this?  
This is right out of the [manual](https://docs.inductiveautomation.com/display/DOC81/system.tag.configure) minus comments.

```auto
parentPath = "[NewProvider]SomeFolder"
configs = system.tag.getConfiguration(parentPath + "/AnotherFolder", True)
 
for tag in configs[0]['tags']:
    if str(tag['tagType']) != 'Folder':
        tag['enabled'] = False
 
system.tag.configure(parentPath, configs, "o")

```

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 14, 2022, 12:53am UTC](https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443/3 "2022-04-14T00:53:48Z")

</div>

That’s exactly the sort of function I was looking for! Thanks a heap, I’ll see if I can manipulate that into something that does what I want and post back.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [May 13, 2022, 9:00am UTC](https://forum.inductiveautomation.com/t/dynamically-disable-a-folder-of-tags-in-a-udt/58443/4 "2022-05-13T09:00:50Z")

</div>

Finally got back to this. So, the approach above worked, with a couple of important things to note for people reading this in the future:

The approach above gets the tag configuration for all tags in the specified folder, modifies it by setting all the “enabled” parameters to false, then writes that modified configuration back to the tags in the folder. _The path to READ the tag configuration is not the same as the path to WRITE the configuration._ That is, when you _read_ the tag config, you specify the folder that all the tags are in. When you _write_ the tag config, you specify the _parent folder_ of the folder your tags are in.

All memory and OPC tags in the folder now show quality `Bad_Disabled`, but expression tags that reference those memory/OPC tags show `Error_ExpressionEval`, not `Bad_Disabled`, despite the fact that they too are disabled and shouldn’t be trying to evaluate an expression. Not a show stopper, but somewhat odd.

So the complete solution for posterity is:

1. A UDT parameter called `Clock AOI Tag`
2. A folder at the base level of the UDT called `Clock`, housing all the tags I want to disable if a Clock AOI is not used
3. An expression tag called `ClockEnabled` at the base level of the UDT, which uses the following expression:

```auto
if(isNull({Clock AOI Tag}) || {Clock AOI Tag} = '', false, true)

```

1. A tag event script (value changed) on that expression tag as follows:

```auto
if currentValue.quality.isGood():
    basePath = '[.]'
    tagConfig = system.tag.getConfiguration(basePath + '/Clock', True)
    for tag in tagConfig[0]['tags']:
        if str(tag['tagType']) != 'Folder':
            tag['enabled'] = currentValue.value
    system.tag.configure(basePath, tagConfig, 'o')

```
