How to write to a table component using system.tag.queryTagHistory?

Good morning, my name is Felipe and I have been studying ignition hard, but I am still very young on the platform. I have been studying a way to write in a table component by clicking on the mouse using the system.tag.queryTagHistory function, I don’t know is possible, and if so, I would like to know what I’m doing wrong? used as reference in startdate the following expression in a text field component:

dateArithmetic({Setup_Plant/Plant01/CurrentShiftStart1},-1, 'days')

the enddate reference I used the following expression in the text field 1 component:

dateArithmetic({Setup_Plant/Plant01/CurrentShiftStart1},0, 'days')

and in the button component scripting component, in the event handlers >> mouse clicked I used the expression:

startdate =event.source.parent.getComponent('Text Field').text
enddate = event.source.parent.getComponent('Text Field 1').text
	
pathlist = []
namelist = ["TimeStamp"]
name = "necker0101"
historyTagPath = "[ign_Historical]Machines_DM/" + name + "/count_discharge"
pathlist.append(historyTagPath)
infeedName = name + "_discharge"
namelist.append(infeedName)	
#	name = "necker0201"
#	historyTagPath = "[ign_Historical]Machines_DM/" + name + "/count_discharge"
#	pathlist.append(historyTagPath)
#	infeedName = name + "_discharge"
#	namelist.append(infeedName)				
data['hourly_counts'] = system.tag.queryTagHistory(paths=pathlist, aggregationMode='Sum', columnNames=namelist, startDate=startdate, endDate=enddate, intervalHours=1, noInterpolation=True)
data['hourly_counts'] = event.source.parent.getComponent('Table').data

I really don’t know if it’s possible, I’m just testing it for another application and also to improve my knowledge in other scripting functions. because I believe you could do this using the system.dataset.toDataSet

The “data[‘hourly_counts’]” looks like how you would create a dataset in a report. Scripting on a vision screen is different. Assuming what you wrote through your queryTagHistory function is right then you just need to change the bottom two lines to write it into your table. This is also assuming your component name is ‘Table’.

hourly_counts = system.tag.queryTagHistory(paths=pathlist, aggregationMode='Sum', columnNames=namelist, startDate=startdate, endDate=enddate, intervalHours=1, noInterpolation=True)
event.source.parent.getComponent('Table').data = hourly_counts

You can also do:

event.source.parent.getComponent('Table').data = system.tag.queryTagHistory(paths=pathlist, aggregationMode='Sum', columnNames=namelist, startDate=startdate, endDate=enddate, intervalHours=1, noInterpolation=True)

The system.tag.queryTagHistory should return a dataset so you don’t need to convert it to one.

1 Like

worked perfectly.

thank you very much