Using system.tag.queryTagHistory into a value change event

Hello.
I am trying to read the historical data from a tag value change script of another member of the UDT.
So, from value change of TAG A I want to query the historical records of TAG B, both are in the same UDT.
The data is there, I can run the code from Scripting Console but it is not working from the value change.
Will it works or am I doing something wrong?

You should be able to get this to work. There's probably some nuance of tag path syntax that varies for the two call origins. (The designer script console is Vision scope, not Gateway scope.)

However, you definitely should NOT do this. Tag value change events (defined on the tag) are expected to run in a very short time (like, single digit milliseconds), which cannot be reliably achieved with any operation that calls out to a database or other network location. If you break this rule, you will eventually experience tag event stalls because the thread threads allocated to do this are all busy with long tasks.

What are you actually trying to do?

1 Like

Hello.
Thanks for your answers and comments.
The challenge is the following, I have tag A and tag B, tag A is a bool tag, a sensor that activates when a cargo is placed in the floor.
Tag B is the speed of the motor that lifts that cargo, human controlled.

When tag A is trigger (Changes to True) I need to search in the historical records of tag B and find when in time the speed was less than 30% so I can report to the operator the slow down time used and he can improve it.
I request around 20 seconds of data only, I get around 4 to 5 records, not that much but thanks for the comment about performance.

I tried with a DataSet but not clear to me how to use a dataset from the value change to add rows and check that rows later.

I make it works, it is a path issue, it needs to be the full path with the provider, when using any other path type like reference on UDT or like it is not working.

You need to move this logic into a Gateway Tag Change Event in a project, instead of using the tag's valueChange event.