casian
March 10, 2026, 10:53pm
1
Hi,
Can someone please help with exporting the Alarm Journal to an excel file, in a Perspective Edge project?
So far I’ve tried a script to a button but doesn’t work
def runAction(self, event):
journal = system.alarm.queryJournal().getDataset()
spreadsheet = system.dataset.toExcel(True, [journal])
filePath = "C:\output\results.xlsx"
system.file.writeFile(filePath, spreadsheet)
This function (probably) does not do what you think it does in a Perspective context. Perspective scripts are actually running on the gateway, so this will be attempting to write to a file on the C drive wherever the gateway is installed, not wherever your browser session is running.
You (probably) want the system.perspective.download function.
casian
March 10, 2026, 11:34pm
3
Much appreciated!
It works but it still pops and error with this in the Output Console: [AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil -- Unable to run action 'dom.onClick' on Main Views/Alarm Journal@D/root/CoordinateContainer: code could not be compiled.
java.lang.Throwable: SyntaxError: no viable alternative at character '�??' (function:runAction , line 2)
Here’s my script now:
def runAction(self, event):
journal = system.alarm.queryJournal().getDataset()
spreadsheet = system.dataset.toExcel(True, [journal])
system.perspective.download(filename="AlarmJournalExport.xlsx", data=spreadsheet, contentType="application/vnd.ms-excel")
I put something like this together, to be used with an Alarm Journal table:
alarmTable = self.getSibling("AlarmJournalTable")
priorities = []
if alarmTable.props.filter.priorities.diagnostic == True:
priorities.append(0)
if alarmTable.props.filter.priorities.low == True:
priorities.append(1)
if alarmTable.props.filter.priorities.medium == True:
priorities.append(2)
if alarmTable.props.filter.priorities.high == True:
priorities.append(3)
if alarmTable.props.filter.priorities.critical == True:
priorities.append(4)
states = []
if alarmTable.props.filter.events.cleared == True and alarmTable.props.filter.events.acked == False:
states.append(0)
if alarmTable.props.filter.events.cleared == True and alarmTable.props.filter.events.acked == True:
states.append(1)
if alarmTable.props.filter.events.active == True and alarmTable.props.filter.events.acked == False:
states.append(2)
if alarmTable.props.filter.events.active == True and alarmTable.props.filter.events.acked == True:
states.append(3)
if alarmTable.props.filter.events.enabled == True:
states.append(4)
if alarmTable.props.filter.events.disabled == True:
states.append(5)
# get alarms
alarms = system.alarm.queryJournal(
startDate=alarmTable.props.dateRange.historical.startDate #date
, endDate=alarmTable.props.dateRange.historical.endDate #date
, journalName=alarmTable.props.name #string
, priority=priorities #list
, state=states #list
#, path=[alarmTable.props.filter.conditions.source] #list
, source=[alarmTable.props.filter.conditions.source] #list
, displaypath=[alarmTable.props.filter.conditions.displayPath] #list
#, all_properties # List[Tuple[String, String, Any]]
#, any_properties # List[Tuple[String, String, Any]]
#, defined # list[String]
, includeData=True #False
, includeSystem=False
, includeShelved=False
, isSystem=False
, provider=[alarmTable.props.filter.conditions.provider] #list
) # a list of PyAlarmEvent objects
# convert to dataset
dataset = alarms.getDataset()
#headers = ['name', 'source', 'priority', 'desc']
#rows = []
#for r in results:
# system.perspective.print(r)
# #Event[name=Alarm, source=prov:Regal_Transport:/tag:P04 WB Silos/Motors/AL_DIS_205/Sts_Alarm:/alm:Alarm, priority=Low, desc=null]
# rows.append([ r['name'], r['source'], r['priority'], r['desc'] ])
#
#dataset = system.dataset.toDataset(headers, rows)
# download
datenow = str(system.date.format(system.date.now(), "yyyy-MM-dd_HH:mm"))
spreadsheet = system.dataset.dataSetToExcel(1, [dataset], 0)
system.perspective.download("alarm-journal-" + datenow + ".xls", spreadsheet)