[Bug] queryTagHistory from project script

This function always gives None value.
I’m basically using the script provided with Demo project source (function is queryHistory). However, if I run basic instructions from Script Console I get values (see attachments).

Show your code. Note that many functions have additional requirements when called from a gateway script versus client/designer. Defaults for tag providers and database connections are typically unavailable, requiring explicit selection in the calls.

def queryHistory(inTags, value, formatDate=False):
ret = []

tagPaths = list()
tagPaths.append('S082170115122/FeedRateOverride') #with [default] is not working either

aggregationMode = None
if value.calc != None and len(value.calc):
	aggregationMode = value.calc

intervalMinutes = 1
if value.interval.units == "min":
	intervalMinutes = value.interval.duration
elif value.interval.units == "hour":
	intervalMinutes = value.interval.duration * 60
elif value.interval.units == "day":
	intervalMinutes = value.interval.duration * 60 * 24

data = None
if value.mode == "realtime":
	rangeMinutes = 5
	if value.date.mostRecent.units == "min":
		rangeMinutes = value.date.mostRecent.duration
	elif value.date.mostRecent.units == "hour":
		rangeMinutes = value.date.mostRecent.duration * 60
	elif value.date.mostRecent.units == "day":
		rangeMinutes = value.date.mostRecent.duration * 60 * 24

	data = system.tag.queryTagHistory(paths=tagPaths, rangeMinutes=rangeMinutes, intervalMinutes=intervalMinutes, aggregationMode=aggregationMode) 
elif value.mode == "historical":
	data = system.tag.queryTagHistory(paths=tagPaths, startDate=value.date.range.start, endDate=value.date.range.end, intervalMinutes=intervalMinutes, aggregationMode=aggregationMode)


if data != None:
	for i in range(data.getRowCount()):
		rowDict = {}
		
		if formatDate:
			rowDict["t_stamp"] = system.date.format(data.getValueAt(i, "t_stamp"), "yyyy-MM-dd HH:mm:ss")
		else:
			rowDict["t_stamp"] = data.getValueAt(i, "t_stamp")
			
		rowDict[tagPath[0]] = data.getValueAt(i, 1)				
		ret.append(rowDict)
		
return ret

Your script notes that “with [defaul] is not working”. Try with the database connection name – that’s usually the name of the history provider.