# KeyError in Script Event

**URL:** <https://forum.inductiveautomation.com/t/keyerror-in-script-event/100516>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [January 7, 2025, 2:41am UTC](https://forum.inductiveautomation.com/t/keyerror-in-script-event/100516 "2025-01-07T02:41:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 7, 2025, 2:41am UTC](https://forum.inductiveautomation.com/t/keyerror-in-script-event/100516/1 "2025-01-07T02:41:49Z")

</div>

Hi all,  
I am attempting to change a property value in a script event.  
Here is the code I have:

```python
	table = self.getSibling("Table_0")
	columns = table.props.columns
	rowStyle = {'background-color':'var(--warningSecondary)'}
	newRow = {}
	
	for col in columns:
		if col.field == 'ReqID':
			pass
		newRow[col.field] = {'value': pyds.getValueAt(0,col.field), 'action':'update', 'enabled':True, 'display':True, 'style':rowStyle}
	
	newRow['updateMe'] = True
	newRow['deleteMe'] = False
	system.perspective.print(newRow['PartNumber']['enabled'])

```

This all works fine. BUT, if I add `newRow['PartNumber']['enabled'] = False` before the print statement, I get a `KeyError`. Why do I get this error and why can I not change this value?

EDIT:  
I just discovered that I can change that value like this, by including it in the loop with an `if` statement:

```python
	    for col in columns:
	        if col.field == 'ReqID':
	            pass
	        newRow[col.field] = {'value': pyds.getValueAt(0,col.field), 'action':'update', 'enabled':True, 'display':True, 'style':rowStyle}
	        if col.field == 'PartNumber':
	        	newRow['PartNumber']['enabled'] = False

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 7, 2025, 7:43am UTC](https://forum.inductiveautomation.com/t/keyerror-in-script-event/100516/2 "2025-01-07T07:43:32Z")

</div>

> [@mdemaris](#):
>
> I get a `KeyError`

What was the exact error ?

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [January 7, 2025, 4:50pm UTC](https://forum.inductiveautomation.com/t/keyerror-in-script-event/100516/3 "2025-01-07T16:50:11Z")

</div>

```python
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 41, in runAction
KeyError: 'PartNumber'

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:runAction>", line 41, in runAction
KeyError: 'PartNumber'

```
