# Alarm Notification Pipeline Shared Script Write to DB

**URL:** <https://forum.inductiveautomation.com/t/alarm-notification-pipeline-shared-script-write-to-db/25911>\
**Category:** Ignition\
**Created:** [June 18, 2019, 2:51pm UTC](https://forum.inductiveautomation.com/t/alarm-notification-pipeline-shared-script-write-to-db/25911 "2019-06-18T14:51:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [June 18, 2019, 2:51pm UTC](https://forum.inductiveautomation.com/t/alarm-notification-pipeline-shared-script-write-to-db/25911/1 "2019-06-18T14:51:35Z")

</div>

Hello,

I have the following shared script:

```auto
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…

---

<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:** [June 18, 2019, 2:53pm UTC](https://forum.inductiveautomation.com/t/alarm-notification-pipeline-shared-script-write-to-db/25911/2 "2019-06-18T14:53:52Z")

</div>

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