# Add alarm event with storeTagHistory

**URL:** <https://forum.inductiveautomation.com/t/add-alarm-event-with-storetaghistory/11371>\
**Category:** Ignition\
**Created:** [March 16, 2016, 10:21pm UTC](https://forum.inductiveautomation.com/t/add-alarm-event-with-storetaghistory/11371 "2016-03-16T22:21:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [March 16, 2016, 10:21pm UTC](https://forum.inductiveautomation.com/t/add-alarm-event-with-storetaghistory/11371/1 "2016-03-16T22:21:57Z")

</div>

I’m using system.tag.storeTagHistory() to manually add historical data to a tag. What I’d like is to also add an (historical) event to the alarm journal for any value that would have triggered an alarm had it been an actual live tag value.  
The only way I see at the moment to achieve this is by sequentially checking each alarm condition on the tag for each value to see if the value would have activated the alarm. Then, if the alarm was activated, directly writing to the alarm\_events table in the database.  
I think this should be possible, though non-trivial, but one thing I’m unsure about is how to generate a unique event id (aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa) when inserting an event into the database.

Any ideas, or suggestions for a much simpler approach?

---

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [March 21, 2016, 5:27am UTC](https://forum.inductiveautomation.com/t/add-alarm-event-with-storetaghistory/11371/2 "2016-03-21T05:27:51Z")

</div>

I’ve now written a script that analyses the alarm conditions for a tag when adding historical data and returns a list of ‘alarm events’ for that data. Now, I want to add these events to the alarm journal by writing to the alarm\_events database table.  
The problem still is creating a unique eventid that matches the exisiting format (which appears to be [8 hex-digits]-[4 hex-digits]-[4 hex-digits]-[4 hex-digits]-[12 hex-digits]).  
Does anyone know how to go about properly generating this?
