tableDS.append([defect, count, level]) line giving me issues saying object has no attribute 'append'.
Honestly stuck as this was working code and now it's not.
Thanks!
def defineLevel(count):
if count >= 0 and count < 3:
level = 0
if count >= 3 and count < 5:
level = 1
if count >= 5 and count < 8:
level = 2
if count >= 8:
level = 3
return level
end = system.date.now()
start = system.date.addHours(end, -8)
params = {"start":start, "end":end}
ds = system.db.runNamedQuery("QualityDisplays", "Escalation/Table", params)
tableDS = []
headers = ["Defect", "Count", "Level"]
for i in range (ds.getRowCount()):
defect = ds.getValueAt(i,0)
count = ds.getValueAt(i,1)
level = defineLevel(count)
tableDS.append([defect, count, level])
tableDS = system.dataset.toDataSet(headers, tableDS)
system.tag.write("[.]Active Dataset", tableDS)
I think it is an indent issue. You assigned tableDS to an empty list and then append to it on every iteration. But you reassign it the result of the toDataSet so in the second iteration it is no longer a list, it is a DataSet.
But you probably only intended to do the toDataSet once after the loop had finished.