Memory Tag value is overridden when hitting OK in tag editor properties

Ignition 7.9.11
We created an Expression tag (partCounter) with a valueChanged Tag Event that uses system.tag.write() to update a Memory tag (outfeedCounter) anytime partCounter changes. We then store the value of outfeedCounter Memory tag in a database.

Everything works fine until we open the Tag properties of outfeedCounter Memory tag and later hit OK or Apply. It appears the “value” property shows the most current value (at the time the tag editor is opened) and if we wait a few seconds, long enough for the Expression tag partCounter to change and hit OK or Apply, the “stale” value shown in the tag editor gets written to the outfeedCounter Memory Tag and causes issues when we store it in the database because it’s less than the current value.

Does anyone know how to get around this? We have played with initialChange but I think hitting OK or Apply causes the value in the Tag editor window to re-write the value on the tag after an initialChange event so it doesn’t help.

Sounds to me like you should be recording the expression tag, and not even have the memory tag.

Thanks for the reply, Phil.

We are using the Expression Tag to do some simple checking for negative numbers, nulls, and tag.quality before writing to the Memory Tag. Kind of like a data cleanser.

Additionally, we assumed Memory Tags are written to disk, persist, (and initially) load better on Gateway restarts than Expression tags.

If you need persistence, then a memory tag is probably what you need. Unless you can get your database to do it for you. Which, since you are recording to a DB, is probably the better solution. If you really want the memory tag to be your persistence, consider another boolean that you can use to disable the event script. Or just accept that whoever edits such an important memory tag must clean up after themselves (correcting the count or whatever).