# Filter Alarm Status Table

**URL:** <https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 14, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239 "2024-10-14T20:00:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oscar\_Serrano](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@Oscar\_Serrano](https://forum.inductiveautomation.com/u/Oscar_Serrano)\
**Post date:** [October 14, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/1 "2024-10-14T20:00:08Z")

</div>

Hello!!

I'm working in Perspective and I am trying to filter some alarms at the Alarm Status Table. So, I'm using the extension function of the table "filter Alarm". At my script I am using the alarm.Event.get() function, and the property which I want to use to filter the Alarms is 'displaypath', but when I'm using that property no one alarm is show up at the table.

So, my question is, is possible use this property with that function? If that is true, how can I use it??

Here is a pic of my script

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/959dd4ced61562456b04a79d82d6fed2486ead65.png)

---

<div class="post-metadata">

**Author:** ![Benjamin\_Furlani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benjamin_furlani/32/66084_2.png) [@Benjamin\_Furlani](https://forum.inductiveautomation.com/u/Benjamin_Furlani)\
**Post date:** [October 14, 2024, 8:04pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/2 "2024-10-14T20:04:26Z")

</div>

I believe it is camel case so `'displayPath'`

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 14, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/3 "2024-10-14T21:12:31Z")

</div>

Okay, first, posting only screen shots of code can be frustrating, you should post the formatted code. If you want to provide a screen shot to give more context that's great but you should always post any code in question as preformatted text.

See:

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Code block formatting Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code] Note that all the \</\> button does is add three backticks ``` on the line before the code block and anot…

Second, you don't need to use the `get()` function, you can just reference the property directly.

Third, the comment above your conditional does not match what the logic is doing. It says that you want to display alarms without a matching display path, but the logic is doing the opposite of that.

Finally, your conditional can be cleaned up and optimized so you're minimizing the amount of time it takes to filter the table.

```python
def filterAlarm(self, alarmEvent):

	# Retrieve the Grupo property from the alarm event
	grupo = alarmEvent.displayPath
	
	# Correctly retrieve the checkbox selections from the view's custom properties
	nodo1Selected = self.custom.Nodo1
	nodo3Selected = self.custom.Nodo3
	nodo5Selected = self.custom.Nodo5
	
	possibleGrupo = ['Nodo 1','Nodo 3','Nodo 5']
	# If no checkboxes are selected, show alarms with no Grupo value
	if not (any([nodo1Selected,nodo3Selected,nodo5Selected])) and grupo not in possibleGrupo:
		return True
	# Show alarms that match the selected nodes
	elif any([grupo == 'Nodo 1' and nodo1Selected,grupo == 'Nodo 3' and nodo3Selected,grupo == 'Nodo 5' and nodo5Selected]):
		return True
	return False

```

The use of the `any()` built-in allows for short-circuiting the evaluation, so as soon as a checkbox is seen as being true it will return instead of evaluating all options.

Once a return is evaluated, no code beyond that point will be processed, I have factored out all of your `else return False` statements to the end of the conditional. In python an `else if` condition is signaled by the `elif` keyword, so I have used here as well. These changes I believe make the code much more readable.

---

<div class="post-metadata">

**Author:** ![Oscar\_Serrano](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@Oscar\_Serrano](https://forum.inductiveautomation.com/u/Oscar_Serrano)\
**Post date:** [October 15, 2024, 12:37am UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/4 "2024-10-15T00:37:04Z")

</div>

Hello Sr,

Got it, thank you for you answer an I appreciate the advices about the code, promise next time I will add the code to the comments.

I did your code, but it did not work, think it was because of "any" when I put it in ignition, ignition does not recognize it.

I used the "get" at the alarmEvent because as you can see at the pic the extension function use the get and into it the property name

When I use the alarmEvent.displayPath it brings me all the alarms and not the filter ones

---

<div class="post-metadata">

**Author:** ![Oscar\_Serrano](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@Oscar\_Serrano](https://forum.inductiveautomation.com/u/Oscar_Serrano)\
**Post date:** [October 15, 2024, 12:37am UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/5 "2024-10-15T00:37:22Z")

</div>

Did it and did not work

---

<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:** [October 15, 2024, 12:40am UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/6 "2024-10-15T00:40:00Z")

</div>

> [@Oscar\_Serrano](#):
>
> did not work

You'll need to provide more detail than just that. Copy the full error messages and paste here as pre-formatted text.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 15, 2024, 2:26am UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/7 "2024-10-15T02:26:27Z")

</div>

> [@Oscar\_Serrano](#):
>
> I did your code, but it did not work, think it was because of "any" when I put it in ignition, ignition does not recognize it.

Whatever the error you got was, it would be very odd that `any()` wouldn’t be ‘recognized’. I use it all the time in ignition.

It’s quite possible that there is an error in my code, as I did not test it, it is also quite likely that there is some type of copy/paste error.

As Phil suggested, provide the error messages and we can give guidance as to how to clear them up.

---

<div class="post-metadata">

**Author:** ![Oscar\_Serrano](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@Oscar\_Serrano](https://forum.inductiveautomation.com/u/Oscar_Serrano)\
**Post date:** [October 15, 2024, 5:22pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/8 "2024-10-15T17:22:54Z")

</div>

Ok This is my code at this moment. Something simple as:

```python
def filterAlarm(self, alarmEvent):
	displayPath = alarmEvent.get('displayPath')
	
	Nodo1Selected = self.custom.Nodo1
	
	if displayPath == 'Nodo 1' and Nodo1Selected:
		return True
	else:
		return False

```

This code is at my Extension Function:Filter Alarm and I am trying to filter the alarms which have at their displayPath a parameter which is "Nodo 1". I said parameter because those tags are into a UDT, but when I try to use the displayPath as a 'propertyName' it does not work, but if I use the label or an associated data it work, it filter the alarms and show them up at the table.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b65658361435386ebe30c20c0b41fbff6687cc7b.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/30e8a9f4750a0d08e761bcb34192ac023f9995f8.png)

There are two pictures where in one I'm using "label" and in the other one I'm using "displayPath" as a propertyName

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 15, 2024, 5:40pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/9 "2024-10-15T17:40:46Z")

</div>

Your displayPath is coming back as a stringPath,  
You need to compare it as a string  
`displayPath = str(alarmEvent.get('displayPath'))`

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 15, 2024, 5:58pm UTC](https://forum.inductiveautomation.com/t/filter-alarm-status-table/97239/10 "2024-10-15T17:58:10Z")

</div>

This will work:

```python
def filterAlarm(self, alarmEvent):
    displayPath = alarmEvent.displayPath.toString()
    Nodo1Selected = self.custom.Nodo1

    if displayPath == 'Nodo 1' and Nodo1Selected:
        return True
    return False

```

I tested this and it works as expected.

For what it's worth you could just use `alarmEvent.label` too. That worked in your example because the AlarmEvent.getLabel() returns a string.
