Force Expression Tag Evaluation


Is there a way to force an expression tag to re-evaluate (or re-execute) its expression?
I have them setup as On Change expressions, which is great for efficiency sake. However, I now lack the ability to force a 'refresh' on demand. A script would be perfect but looking through the system functions, I don't see one that is usable.

Could I utilize a system.tag.configure() without screwing things up? In the past I have used this script for a similar function and it ended up overwriting various properties on the tag (its a UDT instance)


Why? What's the expression you're using?

It is running a script that executes a named query. I went this route to take advantage of Ignitions named query cache feature

Does this expression have any dependencies? If so, consider using a gateway tag change event subscribed to those dependencies, which then calls a project library script to do the work. (And write to the target, converted to a memory tag.) Call that same library script by any other method to "refresh".

It has a dependency of another tag in the UDT, a memory tag, essentially holding the Id of the record I want to return (but be cached, where possible).

I considered going the gateway tag change event route, but this could be on a dynamic number of UDT instances, and I would hate to have the overhead of adding to the event each time another ones gets instantiated.

Side note: I got system.tag.configure() to work on the expression tag by simply 'editing' the tag name (with collision policy = 'm'). But it only worked once.. it was strange.. the first execution, the expression re-ran and it worked. But any subsequent execution, whether from designer or gateway scope, it does not re-evaluate.

Edit: It works the first time, any time the tag configuration changes. I got it to work 1x more time by adding the "dataType" to the new configuration.

Edit Edit: It seems as though any time a tag property gets edited via system.tag.confgure(), it overrides the parent property from the UDT definition. That's fine, but once it is "overridden", any changes to it no longer trigger the expression to re-evaluate. Only the first time it goes from parent > overridden does it force a re-initialization

Not sure this solution will cause issues down the road, but I found a property that when changed causes a expression re-evaluation.

Since the tag has an Event Driven execution mode, I can change the exeuctionRate property to a different value and it will cause the expression to re-evaluate, every time. I am using a script that pulls the current milliseconds, divides it by 10, and adds it to 500 (the default value, apparently, on Event Driven tags). That way if it does have an affect on something, it never actually strays too far from its original value, but it does change every time (unless I get incredibly unlucky)

It works for me