# Showing most recent alarms in vision alarm status table

**URL:** <https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [September 29, 2021, 5:59pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460 "2021-09-29T17:59:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [September 29, 2021, 5:59pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/1 "2021-09-29T17:59:48Z")

</div>

Hello everyone,

I am trying to show the most recent alarms during the past 8 hours in the Alarm status table. Tried to find a way to do this but could not find any answer. Currently, I am seeing all the alarms but I want to limit this information to only the past 8 hours of alarm data. Appreciate any information/reference you could share.

Thank you!

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [September 29, 2021, 7:39pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/2 "2021-09-29T19:39:26Z")

</div>

Here you go:

[https://docs.inductiveautomation.com/display/DOC79/system.alarm.queryStatus](https://docs.inductiveautomation.com/display/DOC79/system.alarm.queryStatus)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 29, 2021, 7:59pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/3 "2021-09-29T19:59:52Z")

</div>

Entirely within the Alarm Status Table, you could also use the `filterAlarm` extension function to hide alarms outside your time window.

I have some reservations about the idea of hiding alarms purely based on time, but presumably you’ve got other ways to identify or deal with long-running alarm conditions…

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 12, 2021, 2:42pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/4 "2021-10-12T14:42:47Z")

</div>

Thank you for your response!  
I have tried to use the link you provided but could not find a way to do this. How can I use [system.alarm.queryStatus] to filter for the last 8 hours alarm?

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 12, 2021, 2:47pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/5 "2021-10-12T14:47:59Z")

</div>

Could not find any example in the manual or within this forum. Would you please provide an example of how this can be done using filterAlarm component scripting? Or is it possible to filter based on the Active time column?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 12, 2021, 3:08pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/6 "2021-10-12T15:08:48Z")

</div>

`alarmEvent.get('ActiveTime')` will give you the time of the column

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 12, 2021, 3:43pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/7 "2021-10-12T15:43:30Z")

</div>

I have tried that but not sure how can I use this information to filter the last 8 hours alarm.  
The information I get from " `alarmEvent.get('ActiveTime')`" is:

Tue Oct 12 **11:09:58** EDT 2021

How can I filter just the time to 8 hours? I am not able to find any example so that I can build mine based on that.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 12, 2021, 3:49pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/8 "2021-10-12T15:49:12Z")

</div>

`filterAlarm` is fired once per alarm event and is required to return a boolean (in Java’s pseudo-functional parlance, a predicate).

So your implementation of `filterAlarm` simply needs to check whether the alarm’s `ActiveTime` is outside of your window.  
You can use [`system.date.now`](https://docs.inductiveautomation.com/display/DOC81/system.date.now) to retrieve the current time during script execution.  
You can use [`system.date.addHours`](https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58603988) to _subtract_ eight hours from a given date.  
You can use `alarmEvent.get("ActiveTime")` to get the time of your event.  
You can use [`system.date.isAfter`](https://docs.inductiveautomation.com/display/DOC81/system.date.isAfter) to compare two different dates and return a boolean (true/false).

Between those functions, you should be able to do what you want.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 12, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/9 "2021-10-12T15:51:53Z")

</div>

Thank you very much, Paul. Appreciate the information.

---

<div class="post-metadata">

**Author:** ![Taylor\_McDaniel](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Taylor\_McDaniel](https://forum.inductiveautomation.com/u/Taylor_McDaniel)\
**Post date:** [May 1, 2022, 3:45pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/10 "2022-05-01T15:45:08Z")

</div>

there should be a training module to help wit this and we should not have to hunt everywhere to get a simple filtering example. There not a example in user manual. Powerful software for Scada but most plant personnel with not be able to support project moving forward.

---

<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:** [May 2, 2022, 2:39am UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/11 "2022-05-02T02:39:28Z")

</div>

There actually is an [example](https://docs.inductiveautomation.com/display/DOC81/How+to+Filter+by+Associated+Data+on+the+Vision+Alarm+Status+Table) in the documentation, though its not for this exact scenario. I don’t know what type of positions plant personnel referrers to, but i wouldn’t expect end users to know how to do this, i would build it in for them.

---

<div class="post-metadata">

**Author:** ![kipton\_nickell](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@kipton\_nickell](https://forum.inductiveautomation.com/u/kipton_nickell)\
**Post date:** [June 8, 2022, 7:58pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/12 "2022-06-08T19:58:22Z")

</div>

Scripts\filterAlarm

return (dateDiff(alarmEvent.get(“ActiveTime”), system.date.now(), “minute”) \< 30)

Reference the following documents:  
[https://docs.inductiveautomation.com/display/DOC79/dateDiff#:~:text=This%20function%20is%20used%20by%20Ignition’s%20Expression%20language.&text=Calculates%20the%20difference%20between%20the,ms](https://docs.inductiveautomation.com/display/DOC79/dateDiff#:~:text=This%20function%20is%20used%20by%20Ignition's%20Expression%20language.&text=Calculates%20the%20difference%20between%20the,ms)  
[https://docs.inductiveautomation.com/display/DOC80/Alarm+Event+Properties+Referenc](https://docs.inductiveautomation.com/display/DOC80/Alarm+Event+Properties+Referenc)

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 20, 2022, 9:41pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/13 "2022-12-20T21:41:46Z")

</div>

I don't think that would work. Datediff is from expression language. System is used in scripting.

I tried this:

```auto
if system.date.hoursBetween(alarmEvent.get('LastActiveTime'),system.date.now())==4:
	   value='true'
else:
		value='false'	
return true 

```

and I tried this

```auto
return 'true' if system.date.hoursBetween(alarmEvent.get('LastActiveTime'),system.date.now())==4 else 'false'

```

I don't know what the property is that I need to look at, or how to find the properties.  
When I look at alarms in the tags, they have this LastActiveTime property.  
When I look at the page [Vision - Alarm Status Table - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Vision+-+Alarm+Status+Table)

I don't see a property that I can use for this.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 21, 2022, 4:55pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/14 "2022-12-21T16:55:17Z")

</div>

I don't think this will work.

It checks when a new alarm populates I think.  
So it will always be recent. Or I need to find the way to make the table call all the events up again.

Either way, I don't know where to find properties accessible with alarmEvent.get()

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 21, 2022, 5:05pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/15 "2022-12-21T17:05:58Z")

</div>

> [@zacharyw.larson](#):
>
> don't know where to find properties accessible with alarmEvent.get()

I encounter this scenario every now and then, and my approach generally starts with directly testing properties that look useful for the problem I am trying to solve.

Here is what I believe to be the current list:  
[https://docs.inductiveautomation.com/display/DOC81/Tag+Alarm+Properties](https://docs.inductiveautomation.com/display/DOC81/Tag+Alarm+Properties)

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 21, 2022, 5:16pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/16 "2022-12-21T17:16:53Z")

</div>

How do you do your testing?

LastActiveTime is listed in the runtime metric properties.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 21, 2022, 5:21pm UTC](https://forum.inductiveautomation.com/t/showing-most-recent-alarms-in-vision-alarm-status-table/51460/17 "2022-12-21T17:21:00Z")

</div>

I generally just print the results to the diagnostic console and see what is returned by my test script
