# RuntimeMenu.JyMenuItem.ScriptError?

**URL:** <https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123>\
**Category:** Ignition\
**Created:** [October 12, 2018, 1:44pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123 "2018-10-12T13:44:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rroca](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rroca](https://forum.inductiveautomation.com/u/rroca)\
**Post date:** [October 12, 2018, 1:44pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123/1 "2018-10-12T13:44:06Z")

</div>

Hi,

I’m trying to run a script in the Client Event Scripts (Menubar) and I got this error and I don’t know what does it mean.

Traceback (most recent call last):  
File “event:menu:Constantes”, line 17, in   
NameError: name ‘event’ is not defined

```
at org.python.core.Py.NameError(Py.java:260)
at org.python.core.PyFrame.getname(PyFrame.java:257)
at org.python.pycode._pyx33.f$0(<event:menu:Constantes>:22)
at org.python.pycode._pyx33.call_function(<event:menu:Constantes>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:634)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:601)
at com.inductiveautomation.factorypmi.application.runtime.RuntimeMenu$JythonMenuActionListener.actionPerformed(RuntimeMenu.java:221)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

```

Ignition v7.9.7 (b2018032914)  
Java: Oracle Corporation 1.8.0\_181

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3fb6b8212ffc86fba164c82fef8cbf99fe28ac6a.png)

Can anybody help me please? 🙏

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 12, 2018, 2:18pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123/2 "2018-10-12T14:18:10Z")

</div>

In line 17 you’re calling event.source.parent.getComponent(), but the menubar scripts don’t get an event parameter, so event is undefined. Sounds like you wanted this script on a button in a window instead?

---

<div class="post-metadata">

**Author:** ![rroca](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rroca](https://forum.inductiveautomation.com/u/rroca)\
**Post date:** [October 12, 2018, 2:22pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123/3 "2018-10-12T14:22:13Z")

</div>

Hi Kathy,

Exactly! I was using that script on a button but now I want to use it in the menu bar, how can I do that?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 12, 2018, 2:43pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123/4 "2018-10-12T14:43:14Z")

</div>

You can’t access a window’s components from a menubar, so you’ll need to rethink what you’re trying to do here. You might need to put the data into a tag that’s bound to the table instead of directly putting it in the table.

---

<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 12, 2018, 3:14pm UTC](https://forum.inductiveautomation.com/t/runtimemenu-jymenuitem-scripterror/20123/5 "2018-10-12T15:14:37Z")

</div>

Well, you have the window that presumably contains the table, so you can replace `event.source.parent` with `window.rootContainer`.

Side note: consider doing this script in window, not in the caller of the window, so it works no matter how you open int. And you really should be using `system.tag.readAll()`, not individual `read()` calls.
