Hello, I am attempting to call queryTagHistory() within the Value Changed script of TagA, to find the history of TagB which resides in the same folder.
This logic will be applied to other tag trees so it needs to reference the relative tag path "[.]TagB"
when getting historical data.
This seems simple enough, but I'm wondering if maybe I am doing something wrong syntactically. Here is the script for Value Changed for tag A
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -1)
dataSet = system.tag.queryTagHistory(paths=["[.]TagB"], startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="Range", returnFormat='Wide')
logger.info(str(dataSet.getValueAt(0,1)))
The logger returns "None" in this instance. But, when I use the very same relative tag path in readBlocking(), the tag data is returned.
tagValue = system.tag.readBlocking(["[.]TagB"])
logger.info(str(tagValue))
Here, the logger returns [[1234567, Good, Thu May 09 14:11:33 CDT 2024 (1715281893803)]] so I know it is getting the right value.
I also tested my same queryTagHistory call with the full path name for TagB instead of the relative path name and I get the correct historical data I am looking for.
dataSetFullPath = system.tag.queryTagHistory(paths=["[provider]path1/path2/path3/TagB"], startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="Range", returnFormat='Wide')
logger.info(str(dataSetFullPath.getValueAt(0,1)))
Accurately yields a valid number.
Would anyone be able to weigh in on why system.tag.queryTagHistory(paths=["[.]TagB"], ...
would not work but system.tag.readBlocking(["[.]TagB"])
does? Thank you in advance