# executableTag.updateCurrentValue() sometimes doesn't work

**URL:** <https://forum.inductiveautomation.com/t/executabletag-updatecurrentvalue-sometimes-doesnt-work/6834>\
**Category:** Module Development\
**Created:** [July 8, 2013, 10:18pm UTC](https://forum.inductiveautomation.com/t/executabletag-updatecurrentvalue-sometimes-doesnt-work/6834 "2013-07-08T22:18:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![idelamer](https://avatars.discourse-cdn.com/v4/letter/i/e5b9ba/32.png) [@idelamer](https://forum.inductiveautomation.com/u/idelamer)\
**Post date:** [July 8, 2013, 10:18pm UTC](https://forum.inductiveautomation.com/t/executabletag-updatecurrentvalue-sometimes-doesnt-work/6834/1 "2013-07-08T22:18:07Z")

</div>

Hi,

I’m trying to update Tag values from within my module. The code is more or less this:

`TagProvider provider = context.getTagManager().getTagProvider("default");
Tag tag = provider.getTag(path);
if (tag instanceof ExecutableTag)
{
    ((ExecutableTag)tag).updateCurrentValue(new BasicTagValue(1, DataQuality.GOOD_DATA));
}
`

The problem I’m having is, this code works from certain threads but not from others.

Works well from: Web server threads, servicing incoming connections. TagChangeEvent calls.  
Doesn’t work from: Tasks registered with the ExecutionManager. Other Threads I start manually. (I use this task to mark Tags as STALE if not updated after a certain amount of time).

I’m testing with the built-in realtime memory tags provider.

Any insight here would be greatly appreciated.

Cheers  
Ivan

---

<div class="post-metadata">

**Author:** ![idelamer](https://avatars.discourse-cdn.com/v4/letter/i/e5b9ba/32.png) [@idelamer](https://forum.inductiveautomation.com/u/idelamer)\
**Post date:** [July 9, 2013, 6:15pm UTC](https://forum.inductiveautomation.com/t/executabletag-updatecurrentvalue-sometimes-doesnt-work/6834/2 "2013-07-09T18:15:24Z")

</div>

Some more information:

The issue seems to be related to using a quality other than “GOOD\_DATA”. If I use GOOD\_DATA then updates work from any context.

If I use “STALE”, then when debugging I notice within updateCurrentValue() there is a call to check if isGoodData(). The update aborts there.

What puzzles me is that I am able to update to “STALE” or “WRITE\_PENDING” from other contexts.

Help here would be appreciated. My goal is to set Tag quality to “STALE” if not updated after a certain timeout.

I’m also updating quality to “WRITE\_PENDING” by subscribing to TagChangeEvent (Property==Value) and that is working fine (from within tagChanged(TagChangeEvent evt)).

Cheers  
Ivan

---

<div class="post-metadata">

**Author:** ![idelamer](https://avatars.discourse-cdn.com/v4/letter/i/e5b9ba/32.png) [@idelamer](https://forum.inductiveautomation.com/u/idelamer)\
**Post date:** [July 9, 2013, 7:01pm UTC](https://forum.inductiveautomation.com/t/executabletag-updatecurrentvalue-sometimes-doesnt-work/6834/3 "2013-07-09T19:01:20Z")

</div>

And a little more information…

I am now testing with a Database Driving Provider. Quality is successfully changed to Stale. But then if I write a new value with “GOOD\_DATA” the quality remains STALE.

Maybe there is something about STALE quality I don’t understand?
