Alarm Notification Pipeline Shared Script Write to DB

Hello,

I have the following shared script:

def insertAlarmNote(asset_name, alarm_name, alarm_transition_code):
t_stamp_note = system.date.now()
	if alarm_transition_code == 1:
		note = asset_name + ": " + alarm_name + " alarm transitioned to active"
	elif alarm_transition_code == 2:
		note = asset_name + ": " + alarm_name + " alarm was acknowledged"
	elif alarm_transition_code == 3:
		note = asset_name + ": " + alarm_name + " alarm transitioned to clear"
	else:
		note = "note error"
	#Insert into db
	try:
		params = {"asset_name":asset_name, "t_stamp_note":t_stamp_note, "note":note, "username":asset_name}
		system.db.runNamedQuery("Insert Note", params)
	except:
		pass
	system.tag.write("[default]Test/Test Tag", 3)

If I call this from a button on a window, it works as expected.
shared.asset_notes.insertAlarmNote("test asset name", "test alarm name", 1)

If I instead call it from an alarm notification pipeline script block, the tag write seems to work but nothing gets written into the db…

Try specifying the project in system.db.runNamedQuery(). Behavior is different in gateway scope.

1 Like