# System.dataset not working in Client Tag Change Script

**URL:** <https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430>\
**Category:** Ignition\
**Created:** [October 27, 2019, 6:29pm UTC](https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430 "2019-10-27T18:29:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ematschke](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ematschke/32/7544_2.png) [@ematschke](https://forum.inductiveautomation.com/u/ematschke)\
**Post date:** [October 27, 2019, 6:29pm UTC](https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430/1 "2019-10-27T18:29:35Z")

</div>

If I use the following code on a button, it works fine. I can call incRow further down in the script.  
But if i use it in a Tag Change Script, I get NameError: global name ‘system’ is not defined

def incRow():  
newData = system.dataset.setValue(table.data, row,0,1) # set value inf first column  
table.data = newData   
value = row + 1 # then increment pointer to move down the list  
table.selectedRow = value # set the selectedRow to the new value

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [October 27, 2019, 6:50pm UTC](https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430/2 "2019-10-27T18:50:15Z")

</div>

It looks like your trying to look at a table on the screen from a tag script. I don’t believe that can be done. Even with it being a client tag it isn’t directly attached to the screen so when the tag changes it doesn’t know where to look. Is it trying to change values in the client tag itself or somewhere else?

---

<div class="post-metadata">

**Author:** ![ematschke](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ematschke/32/7544_2.png) [@ematschke](https://forum.inductiveautomation.com/u/ematschke)\
**Post date:** [October 27, 2019, 7:45pm UTC](https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430/3 "2019-10-27T19:45:09Z")

</div>

“table” is a local variable defined further up in the code  
table = mywindow.getRootContainer().getComponent(‘Tbl\_Inst’)  
This is in a Client Event Script. Tag Change.  
Also if i use the four lines of script elsewhere in the script, it works fine, just not when contained in the incRow function. But since that gets used several times throughout the code i thought it would be more efficient (or at least cleaner looking) to define a function then call it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 27, 2019, 8:40pm UTC](https://forum.inductiveautomation.com/t/system-dataset-not-working-in-client-tag-change-script/29430/4 "2019-10-27T20:40:12Z")

</div>

Event scripts use an ancient jython compatibility mode–a leftover from v7.6.x IIRC. Anyways, one of the side effects of that compatibility mode is that `system`, `shared`, `project`, etc are only automatically present at the top level of the script, not in any nested function or class. You can import them inside the function definition, or, for a more robust solution, delegate from the event to a project script, passing the arguments needed. I like one-liners:

```auto
project.someModule.someFunction(event)

```

It’s also best, if you have repeating code, to put it in a script module, not redefine at every script execution. The only functions that need defining in-line are those that need runtime variables in their closures.
