# Perspective Tag Browse Tree - Show only tags with alarms

**URL:** <https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 1, 2023, 12:51am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406 "2023-06-01T00:51:27Z")\
**Posts on this page:** 10\
**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:** [June 1, 2023, 12:51am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/1 "2023-06-01T00:51:27Z")

</div>

I'm trying to use the filterBrowseNode extension function to display only tags with alarms, but it's proving difficult...

If I use this below, I only get tags with alarms in the root folder:

```auto
	system.perspective.print('{}: {} attr: {}'.format(node.name, node.getDataType(), node.getAttributes()))
	
	if 'alarm' in str(node.getAttributes()):
		return True
	else:
		return False

```

And the print statements show:

```auto
10:20:46.659 [Browser Thread: 62914] INFO Perspective.Designer.Workspace - 5s Clock Pulse: Boolean attr: [NodeAttribute[scripting]]
10:20:46.660 [Browser Thread: 62914] INFO Perspective.Designer.Workspace - Area Filter: DataSet attr: []
10:20:46.660 [Browser Thread: 62914] INFO Perspective.Designer.Workspace - SMS Notification: String attr: []
10:20:46.661 [Browser Thread: 62914] INFO Perspective.Designer.Workspace - Take Thread Dump: Boolean attr: [NodeAttribute[scripting]]
10:20:46.661 [Browser Thread: 62914] INFO Perspective.Designer.Workspace - Test SMS Alarm 2: Boolean attr: [NodeAttribute[scripting], NodeAttribute[alarm]]

```

for this test folder structure:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/4145cce7ffc577b41dcc62691f5e14614472dcee.png)

Note that `SMS Notification/Test SMS Alarm` is completely missing

I've tried adding into the if condition `node.getDataType() == 'Folder'` and also converting to `str` before comparing, ~~but folders don't appear to be Nodes that are ever returned, so this doesn't work to include folders~~ 😕

---

<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 1, 2023, 12:59am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/2 "2023-06-01T00:59:35Z")

</div>

The `SMS Notification` folder is in your printout, so it certainly was handed to your filter. It just lied about its datatype. You might have to do some more introspection to figure out how to detect them.

---

<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:** [June 1, 2023, 1:01am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/3 "2023-06-01T01:01:21Z")

</div>

Oops, you're right. That's annoying still though... I can't use `hasChildren()` because standard tags have children (their properties) 😕 I'll keep digging... it's certainly not easy

---

<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:** [June 1, 2023, 1:03am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/4 "2023-06-01T01:03:11Z")

</div>

Got it, `getObjectType()` returns `'Folder'`

---

<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 1, 2023, 1:03am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/5 "2023-06-01T01:03:56Z")

</div>

Try using `node.getType()`, not just `node.getDataType()`.

---

<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:** [June 1, 2023, 1:05am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/6 "2023-06-01T01:05:00Z")

</div>

So the resulting filter is:

```auto
if 'alarm' in str(node.getAttributes()) or str(node.getObjectType()) in ('UdtInstance', 'Folder'):
	return True
else:
	return False

```

---

<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 1, 2023, 1:05am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/7 "2023-06-01T01:05:33Z")

</div>

You might need another case for UDT instances.

---

<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:** [June 1, 2023, 1:06am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/8 "2023-06-01T01:06:35Z")

</div>

I got excited, haha. Edited my reply to add UdtInstance. What I _really_ want to do is to not show folders/udt instances that don't have alarm tags in them... but I don't think that's possible since the filter is run on each node

---

<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 1, 2023, 1:32am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/9 "2023-06-01T01:32:00Z")

</div>

> [@nminchin](#):
>
> but I don't think that's possible

Cache the folder results in a project library script top-level variable and reference that in your filter.

---

<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:** [June 1, 2023, 1:38am UTC](https://forum.inductiveautomation.com/t/perspective-tag-browse-tree-show-only-tags-with-alarms/74406/10 "2023-06-01T01:38:27Z")

</div>

Ha, that's clever, i'll do that 🙂 thanks!
