Error trying to coerce value with system.dataset.setValue

The script I am testing is taking an data from a table and replacing the integer 1 with ‘Enabled’ or 0 with ‘Disabled’.
I get the following error:

Traceback (most recent call last):
File “event:actionPerformed”, line 7, in
ValueError: Error trying to coerce ‘Enabled’ to a number.



table = event.source.parent.getComponent('Table')
data =

for row in range(data.getRowCount()):
	n2Status = data.getValueAt(row, 'nitro_enable')
	if n2Status == 1:
		newData = system.dataset.setValue(data, row, ('nitro_enable'), str('Enabled'))

Tip: post code (and format it using the </> code formatting button) rather than a pictures of code. That way we can copy and paste it into our answers.

1 Like

Check if you’re trying to force a string into a numeric field. Try adding in a print statement with type(row['nitro_enable']).
If it comes back with a numeric type then that’s your problem.

Other things:

  • You don’t need parentheses in ... data, row, ('nitro_enable') ....
  • You don’t need to convert ‘Enabled’ to a string. It already is one.
1 Like

As @Transistor hinted at, the type of column nitro_enable is numeric. So if you want to convert it you will need to either rebuild the dataset with the system.dataset.* functions, or the DatasetBuilder class.

For reference see:

1 Like

Almost positive that’s the problem. It is either a 1 or 0, I want to replace the number with the string.

Did you try the type() function as I suggested?
Is the database column a text column (what you want) or a boolean / integer column (which is not what you want)?

Paste your updated code (and not a screengrab) and the result.