I have a function that is supposed to dynamically bring in and use tag history when it is called from a gateway event tag change script. A snippet of the code is as follows:
#eventStart and eventEnd are passed to the function as inputs
startTime = system.date.addSeconds(eventStart, -80)
endTime = eventEnd
path = 'Derived Tags/Last Alarm Cause'
aggregationMode = 'Average'
returnFormat = 'Wide'
# Get the data from the historian and select first alarm from dataset. This is the alarm we will be using to classify the event.
dataset = system.tag.queryTagHistory(paths = [path], startDate = startTime, endDate = endTime, aggregationMode = aggregationMode, returnFormat = returnFormat)
When this code is executed in the scripting console, it returns a dataset just fine. However, when the code is executed as part of the gateway event, the dataset returns as empty.
I know the script is able to access the project scope when executed in the gateway, as it successfully performs named queries What could I be missing here?