Alarm cleared and acknowledged data

I want to list alarm events in a report table in 7.7

I’ve found the event data in the database but can’t seem to find where the cleared and acknowledged info is stored?

For me, a frustrating omission is the inability to access the data in the predefined alarm tables.

If I were doing an alarm report in 7.7 I’d make a hidden table on the page and run a script somthing like this, tied to a Date Range component

[code]start = event.source.parent.getComponent(‘Date Range’).startDate
end = event.source.parent.getComponent(‘Date Range’).endDate
cleared = system.alarm.queryJournal(journalName=“Journal”, state=[“ClearUnacked”,“ClearAcked”], startDate = start, endDate = end)
active = system.alarm.queryJournal(journalName=“Journal”, state=[“ActiveUnacked”, “ActiveAcked”], startDate = start, endDate = end)

#dataset to pass to the table
dataset = []
#dataset to check the UUID of each event
checked = []
#Check all active alarms
for alarm in range(len(active)):

id = active[alarm].getId()
#If we have not checked an alarm with this ID...
if id not in checked:
    #...add the UUID to checked
    checked.append(id)
    #get the time the alarm went active and convert it to a string
    #also, I clean up whe is returned
    activeDate = str(active[alarm].getActiveData())[11:22]
    activeTime = str(active[alarm].getActiveData())[22:30]
  #  ack = active[alarm].getValues()
	alarmName = active[alarm].getName()
	DP = active[alarm].getDisplayPath()
	Priority = active[alarm].getPriority()
	State = active[alarm].getState()
	

	
	#The loop that checks for cleared alarms
    for i in range (len(cleared)):
        
        #find the matching cleared event if one exists
        if cleared[i].getId() == id:
        	#format the cleared event time
            clearedTime = str(cleared[i].getClearedData())[22:30]
            clearedDate = str(cleared[i].getClearedData())[11:22]

#Attempt to add the UUID, active time, and cleared time to the dataset named “dataset”.
try:
dataset.append([DP,alarmName,activeTime,activeDate,clearedTime,clearedDate,Priority,State])
#if the append fails because cleared time is NULL, then insert a NULL into that column of the dataset
except NameError:
dataset.append([DP,alarmName,activeTime,activeDate,None,None,Priority,State])
else:
pass

        #Reset clearedTime for the next iteration through the loop
        clearedTime = None

header = [“Name”,“Alarm”,“Active Time”,“Active Date”, “Cleared Time”,“Cleared Date”, “Priority”, “State”,]

dataset = system.dataset.toDataSet(header, dataset)

event.source.parent.getComponent(‘Table’).data = dataset[/code]

You will have to modify it a bit to get the info you need, if you want cleared alarms as well, but it gives you something like the Alarm Journal in a table

You can then make the table one of your data sources.

Thanks Chris, had a go at that, got past a few stumbling blocks but it’s reporting on the line:

id = active[alarm].getId()

“alarm not defined”

any tips?

alarm is defined in the line above

for alarm in range(len(active)):

spelling and case correct?

Hi Chris, strange, I 1st tried this on my laptop and got that error… I moved onto the desktop and copied the code and it worked 1st time… thanks again for your help