Further info:
I only started trying to close the window after a delay after it seemed the last line of the previous version on my script was not doing anything:
user = system.security.getUsername()
if user == 'Guest':
tagPaths = ["[System]Client/Network/Hostname"]
tag = system.tag.readBlocking(tagPaths)
if tag[0].value == 'MyPC':
success = system.security.switchUser('username', 'password')
if success:
windowPath = 'User Management/Switch User'
system.nav.closeWindow(windowPath)
And I added the import system to the defined function because I was getting this error without it:
Traceback (most recent call last):
File "", line 15, in
File "", line 14, in closeWindow
NameError: global name 'system' is not definedat org.python.core.Py.NameError(Py.java:261)
at org.python.core.PyFrame.getglobal(PyFrame.java:265)
at org.python.pycode._pyx2.closeWindow$1(:14)
at org.python.pycode._pyx2.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
at org.python.core.PyFunction.call(PyFunction.java:416)
at org.python.pycode._pyx2.f$0(:16)
at org.python.pycode._pyx2.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1687)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:800)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:769)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:736)
at com.inductiveautomation.factorypmi.application.FPMIApp.startup(FPMIApp.java:486)
at com.inductiveautomation.factorypmi.application.runtime.ClientPanel.lambda$startupApp$8(ClientPanel.java:881)
at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)Ignition v8.1.21 (b2022092908)
Java: Azul Systems, Inc. 11.0.15
and I found a forum thread that told me to import system.