Script error when Create Dataset to a dropdown list

I need to rename the items in the dropdown list where the item names are displayed through a query. The dropdown list shows {1,2,3,4}. So, I need to add 'motor' in the front of every number. {motor 1, motor 2, motor 3 ..ect}
Currently, I am unable to create the dataset in order to send it back to the dropdown list. (I am wiring script transform to query)
Here is the code

datas = system.dataset.toPyDataSet(value) # retrieve table data
columnName=list((value.getColumnNames())) #column name 

Tblist =  datas.getColumnAsList(0) #column data (rows)
	for i in range(datas.getRowCount()):
		newlist += ['Inve No _'+ str(Tblist[I])] #add name to front

newdata=system.dataset.toDataSet(columnName,newlist) #create dataset

Give this error:
I think, the 'Tblist' is taken as a table with multiple columns but here it should be a single column with multiple rows as this table has only one column.


system.dataset.toDataSet is looking for a list of lists for the rows parameter. The += appears to be doing an extend operation instead of an append operation.

Also, dropdowns in vision are looking for a two column dataset, one column is value, other is label. In perspective it looks for a list of dictionaries, with the dictionaries containing the keys value and label.

You can change newlist += ['Inve No _'+ str(Tblist[I])] to be newlist.append(['Inve No _'+ str(Tblist[I])]).

Or, you can replace


newlist = [['Inve No _ {0}'.format(datas.getValueAt(x, 0)] for x in xrange(datas.rowCount)]

If you are trying to transform a query result into something the dropdown can use, your script should only be

newDropdownList = [
		'label': 'Inve No _ {0}'.format(value.getValueAt(x, 0)),
		'value': value.getValueAt(x, 0)
	} for x in xrange(value.rowCount)
1 Like