# Perspective Event Driven Query Tag Expression

**URL:** <https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 29, 2022, 7:29pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487 "2022-07-29T19:29:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.myers](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason.myers](https://forum.inductiveautomation.com/u/jason.myers)\
**Post date:** [July 29, 2022, 7:29pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/1 "2022-07-29T19:29:14Z")

</div>

I’m using 8.1.18. I have a UDT with several query tags. I’d like to make them event driven so they only run when needed rather than pounding my database with a fixed rate execution. I have a tag that lets me know if we are running, which is also a UDT. I want the query tag to fire upon that tag changing. The status tag path is also a parameter of my UDT. So I’ve tried {STATUS\_TAG\_PATH}+“/VALUE” and tag({STATUS\_TAG\_PATH}+“/VALUE”) to no avail. I’ve also put these into an if statement. How do I get this to fire when this tag changes?

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [July 29, 2022, 8:29pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/2 "2022-07-29T20:29:16Z")

</div>

@jason.myers if it were me I’d put my queries into named queries (which return datasets) and then run them from a tag change script on the running status tag. As a UDT it might look something like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/1/b1e3001cea2e0e7b0360d6c63690f2f98c13692c.png)

Nick

---

<div class="post-metadata">

**Author:** ![jason.myers](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason.myers](https://forum.inductiveautomation.com/u/jason.myers)\
**Post date:** [August 3, 2022, 5:43pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/3 "2022-08-03T17:43:14Z")

</div>

That’s a possibility, but just as a general question: how do you get an event driven tag to fire. Does anyone have an example?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 3, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/4 "2022-08-03T18:02:39Z")

</div>

> [@jason.myers](#):
>
> how do you get an event driven tag to fire

That depends on what you mean by 'event driven' and 'firing a tag'. If you mean based on a user interaction that's one thing, based on when a client is currently using the tag value is another, and based on the value of another tag is yet another.

From your OP, I assume you mean based on the value of another tag. That would require configuring a drive tag group and adding any tags you want to executed based on that to that group.

Check out: [Tag Groups - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Tag+Groups)

Particularly the Driven and Leased Tag Group types.

As for "firing" as tag based on some user action, I don't really know what you mean by "firing". You could potentially use `system.opc.readValue(s)()` to read a value directly from a device without having a tag.

I suppose you could also set up a Driven Tag Group as a One Shot based on some memory tag that you have set up as the trigger and then write to the tag value on some user event to force a tag update.

Otherwise they only update their values based upon the Tag Group they are assigned to.

---

<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:** [August 3, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/5 "2022-08-03T18:15:13Z")

</div>

> [@lrose](#):
>
> Otherwise they only update their values based upon the Tag Group they are assigned to.

Someone needs to spend time with event driven tags.

They re-evaluate when any referenced tag within their expression/SQL changes.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 3, 2022, 6:17pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/6 "2022-08-03T18:17:05Z")

</div>

> [@pturmel](#):
>
> Someone needs to spend time with event driven tags.

I rarely use Query Tags. But yes, I was not thinking about non-OPC tags. Good point.

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [August 3, 2022, 9:21pm UTC](https://forum.inductiveautomation.com/t/perspective-event-driven-query-tag-expression/62487/7 "2022-08-03T21:21:24Z")

</div>

From your original post I read you wanted the queries to trigger whenever the running value changes. If that is true, you just use the tag change script on that tag and it will fire whenever the value changes (ex: from True to False would cause the script to run).

Nick
