# Enable/Disable tag history according to another tag value

**URL:** <https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 8, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181 "2023-10-08T12:04:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ali\_Ali](https://forum.inductiveautomation.com/u/Ali_Ali)\
**Post date:** [October 8, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/1 "2023-10-08T12:04:44Z")

</div>

Hello,  
I would like to configure tag to record history on condition only. Let's say I have a Motor and I need to record PLC PID Out value on change but only when the Run Feedback is "true". I noticed I can bind the "History Enabled" property, but I couldn't reference the Run FB tag from the UDT. I thought I may bind it to the OPC path of the Run FB. I need to make sure that won't badly affect the historian, because the tag will be created and retired many times.

 ![Screenshot 2023-10-08 150326](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/54eecabb7f77509ebe5a67206fda42d4edbb4ee6.png)

---

<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:** [October 8, 2023, 12:11pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/2 "2023-10-08T12:11:42Z")

</div>

Bindings for tag properties and UDT parameters are intended to support **configuration** , not **runtime** , and do not support references to runtime tag values. Sorry. You can **write** to the history enabled property from a script during runtime, though.

---

<div class="post-metadata">

**Author:** ![Ali\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ali\_Ali](https://forum.inductiveautomation.com/u/Ali_Ali)\
**Post date:** [October 8, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/3 "2023-10-08T13:30:10Z")

</div>

Thanks @pturmel. So you think the best approach is to write to the history enabled property from a value changed script in the Run FB? Wouldn't that affect the historian?

---

<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:** [October 8, 2023, 1:38pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/4 "2023-10-08T13:38:31Z")

</div>

> [@Ali\_Ali](#):
>
> Wouldn't that affect the historian?

Of course. That's what you want, right?

---

<div class="post-metadata">

**Author:** ![Ali\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Ali\_Ali](https://forum.inductiveautomation.com/u/Ali_Ali)\
**Post date:** [October 8, 2023, 2:31pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/5 "2023-10-08T14:31:37Z")

</div>

No I mean -as I understand- that will create and retire the PID Out tag from the historian each time the Run FB change (true, false) because I enable and disable the PID Out tag history property. Wouldn't that load or bug the historian?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 8, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/6 "2023-10-08T14:37:34Z")

</div>

> [@Ali\_Ali](#):
>
> ... that will create and retire the PID Out tag from the historian ...

No, historian tag entries remain in the sqlth\_te table forever. (It can be a problem sometimes when you wish you hadn't originally put the tag in _that_ history provider but now you've moved it and it still appears as an option on things like Perspective's Power Chart tag browser.)

Enabling and disabling will only affect whether or not it records data in the sql\_dtat\_X\_X history tables.

[https://docs.inductiveautomation.com/display/DOC81/Ignition+Database+Table+Reference](https://docs.inductiveautomation.com/display/DOC81/Ignition+Database+Table+Reference)

Going by that documentation I would expect to see the "retired" show the time the tag's history was disabled or Null if re-enabled.

---

<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:** [October 8, 2023, 3:54pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/7 "2023-10-08T15:54:18Z")

</div>

If you're going to be modifying it this much, then you should just write the history to the historian manually in a Gateway Tag Change script using `system.tag.storeTagHistory()`. Then you can use the other tag as a filter to store or not store changes as needed.

---

<div class="post-metadata">

**Author:** ![DNice](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@DNice](https://forum.inductiveautomation.com/u/DNice)\
**Post date:** [October 9, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/enable-disable-tag-history-according-to-another-tag-value/80181/8 "2023-10-09T13:58:04Z")

</div>

Another alternative is to make a third tag that references the Run Feedback and PID Out tags like below.  
The idea is to enable history on this third tag only. The values will equal PID Out when the Feedback tag is high and None (or alternatively 0) when low.

 ![PID Hist Out Ex](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/d/8d8131f55297fb66d15d662143fcaf7755fa28be.png)
