# One-Shot Expression

**URL:** <https://forum.inductiveautomation.com/t/one-shot-expression/6795>\
**Category:** Ignition\
**Created:** [June 28, 2013, 7:10pm UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795 "2013-06-28T19:10:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [June 28, 2013, 7:10pm UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/1 "2013-06-28T19:10:03Z")

</div>

I am trying to create some information inside ignition - we typically do this in the PLC, but have a lot of remote sites and are trying to cut down on traffic where possible.

What I want to do is grab a start date and time when I get a run indication and then when I lose it grab a stop date and time. I was thinking of using an expression tag, but realized there really isn’t a way to do a one shot that is clean that I can think of.

Initially I though well I can use the expression tag to set another tag and run a script and as long as the other tag and the run status is high I don’t run the script, but when I lose the run and the other tag is high I run another script to grab the stop date. This just seems to convoluted to me, but I guess if it is the only way to do it. Anyone have any suggestion for a more elegant method?

Thanks

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [July 2, 2013, 2:46pm UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/2 "2013-07-02T14:46:50Z")

</div>

Would something like the attached tag structure work as a starting point? (tag export is from 7.5.8 )

A few notes:

-I don’t know if this kind of circular referencing is bad or not.

-I didn’t really pay attention to how run bit quality will affect the behavior (need to force run bit bad and see what happens when it goes good again)

-Before the initial tag change, the tags may evaluate to bad quality. A try call and default value may take care of it, but not sure what you’d want as a default.

Dan  
[ExampleSqltags.csv](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a2be9800f7a404db71080209cfe21422f0623223.csv) (2.46 KB)

---

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [July 10, 2013, 2:06am UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/3 "2013-07-10T02:06:58Z")

</div>

In theory it is a great idea - I tried using it, but when I refer to the LastChange it always comes up null. If I just put a date instead of LastChange it comes up fine. Not sure what is happening there.

Thanks for the file though!

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 10, 2013, 11:22am UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/4 "2013-07-10T11:22:38Z")

</div>

seems like a great use for the gateway tag change scripts. I guess it depends on what you want to do with the data? do you want to put it in tags or save it in the database?

---

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [July 18, 2013, 6:02am UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/5 "2013-07-18T06:02:10Z")

</div>

Well a little bit of both, but I guess I could use a query tag to grab them out of the database. Thanks for the suggestion - I will look into it.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [August 12, 2013, 10:16pm UTC](https://forum.inductiveautomation.com/t/one-shot-expression/6795/6 "2013-08-12T22:16:06Z")

</div>

A triggered transaction group might also be a good choice for this sort of thing.
