# Vision - closing error box popup via scripting

**URL:** <https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [August 11, 2022, 5:24am UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902 "2022-08-11T05:24:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 11, 2022, 5:24am UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902/1 "2022-08-11T05:24:44Z")

</div>

I have tried following as recommended in [this post (Auto - Close Error Box).](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/19)

But i think something has changed in version 8.1 + from 7.9.as it no longer works.

I have manually triggered an error popup from a Vision client, then ran the following code to try understand what windows are currently open:

```auto
from java.awt import Window, Frame 
from javax.swing import JFrame

print "Hostname: %s" % system.net.getHostName() 
windows = Window.getWindows()

for wind in windows: 
	print wind
	print "\n"

```

I get the following output:

```auto
Hostname: VMWIN10-OMRON01
javax.swing.JFrame[frame0,1070,596,419x151,invalid,hidden,layout=java.awt.BorderLayout,title=Launching,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,419x151,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame1,0,0,516x539,invalid,hidden,layout=java.awt.BorderLayout,title=Output Console,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,500x500,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@74a62a7a,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame2,1101,515,755x468,invalid,layout=java.awt.BorderLayout,title=Error,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,739x429,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@4087f750,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame3,1272,690,358x296,invalid,hidden,layout=java.awt.BorderLayout,title=Warning,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,342x257,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@175a9932,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

javax.swing.JFrame[frame4,-8,-8,2576x1320,invalid,layout=java.awt.BorderLayout,title=G1-Line01 - Main Window,resizable,maximized,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,2560x1281,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@5dbaff84,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent[frame5,94,295,2373x865,invalid,layout=java.awt.BorderLayout,title=Diagnostics,resizable,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,2357x826,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@180afbb3,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

javax.swing.JDialog[dialog0,1077,575,405x176,invalid,hidden,layout=java.awt.BorderLayout,APPLICATION_MODAL,title=Update Available,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,8,31,389x137,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@59f3b76a,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

```

However it seems this output and all the Windows printed out is actually the same whether i have the error popup there or not…  
For instance, a window with title = “Error” is there regardless.

I’ve used the following logic to close the error popup, which **seems** to work, but it is frustrating that the “Error” window still shows up after closing it, which makes it hard to write scripts to detect these popups properly.

```auto
for wind in Window.getWindows(): 
	if isinstance(wind,JFrame): 
		logger.debug(wind.getTitle())
		if wind.getTitle() == 'Error': 
			wind.dispose()

```

Is there a better Java class or something to detect the error popups more accurately…?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 11, 2022, 12:18pm UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902/2 "2022-08-11T12:18:14Z")

</div>

According to the docs, that’s expeced behavior:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/5/e5391ef2543e8554c4768cc4a575ac3e142c9252.png)

There is, however, an _isActive()_ function.

```python
for wind in Window.getWindows(): 
	if isinstance(wind,JFrame): 
		logger.debug(wind.getTitle())
		if wind.getTitle() == 'Error' and wind.isActive(): 
			wind.dispose()
```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 11, 2022, 4:55pm UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902/3 "2022-08-11T16:55:38Z")

</div>

You could use the first half of my code here to statically retrieve the error & warning panels:

> [@Getting the Error Messages Dialog Text Through Script](https://forum.inductiveautomation.com/t/getting-the-error-messages-dialog-text-through-script/59983/4):
>
> from com.inductiveautomation.ignition.client.util.gui import ErrorUtil from org.apache.commons.lang3.reflect import FieldUtils errorPanel = FieldUtils.readStaticField(ErrorUtil, "errorPanel", True) warningPanel = FieldUtils.readStaticField(ErrorUtil, "warningPanel", True) errors = FieldUtils.readField(errorPanel, "errors", True) warnings = FieldUtils.readField(warningPanel, "errors", True) for error in errors: print error.title print error.message print error.exception for warning in warn…

That returns an ErrorPanel, which is a JPanel, so you should be able to walk up from it to the JWindow.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [August 12, 2022, 1:47am UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902/4 "2022-08-12T01:47:43Z")

</div>

Thanks Paul, where do i find the latest Java SDK for Ignition?  
I keep coming back to here which is not what i want.  
[https://docs.inductiveautomation.com/display/SE/Ignition+SDK+Programmers+Guide](https://docs.inductiveautomation.com/display/SE/Ignition+SDK+Programmers+Guide)

I’ve tried using the .parent property to “go up the chain”, which gives me the following component heirachy":

```auto

13:18:10.327 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ErrorPanel type: <type 'com.inductiveautomation.ignition.client.util.gui.errors.ErrorPanel'>
13:18:10.329 [AWT-EventQueue-0] INFO Tamaki Scripting - Errors: [com.inductiveautomation.ignition.client.util.gui.errors.DisplayableError@4369c17f]
13:18:10.334 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel type: <type 'javax.swing.JPanel'>
13:18:10.338 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel2 type: <type 'javax.swing.JLayeredPane'>
13:18:10.341 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel3 type: <type 'javax.swing.JRootPane'>
13:18:10.345 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel4 type: <type 'com.inductiveautomation.ignition.client.util.gui.DefaultPopupWindowParent'>
13:18:10.353 [AWT-EventQueue-0] DEBUG Tamaki Scripting - ParentPanel5 type: <type 'NoneType'>

```

Looks like i was able to close it with the dispose() method on the parentPanel4 component.

If anyone in the future is interested in the final code, looks something like this. I intend to actually log the error to a database or something when closing these automatically, so we can try and diagnose the root cause. This is only intended to clear popups from dashboard TV screens that are not easy to access.

```auto
from java.awt import Window, Frame 
from javax.swing import JFrame 
from com.inductiveautomation.ignition.client.util.gui import ErrorUtil
from org.apache.commons.lang3.reflect import FieldUtils

logger = system.util.getLogger("Script Debugging")
scriptName = "dashboardClearErrors"
dashboardHosts = ["G1-1-S001","G1-1-S002","G1-1-S003","G1-1-S004","G1-1-S005","VMWIN10-OMRON01"]

clientName = system.net.getHostName()

if clientName in dashboardHosts:
	logger.debug(scriptName + " - host (%s) in list, attempting to detect errors" % (clientName))
	

	errorPanel = FieldUtils.readStaticField(ErrorUtil, "errorPanel", True)
	warningPanel = FieldUtils.readStaticField(ErrorUtil, "warningPanel", True)
	errors = FieldUtils.readField(errorPanel, "errors", True)
	warnings = FieldUtils.readField(warningPanel, "errors", True)
	
	# errorPanel is of type jPanel which is a child of jWindow component. 
	jWindow = errorPanel.parent.parent.parent.parent	
	####logger.debug("jWindow type: %s" % (type(jWindow)))
		
	if len(errors) > 0:
		# Something there, need to close popup.
		# NOTE: errorPanel component still exists if errors = 0, so need this check
		jWindow.dispose()
		logger.info("Attempting to close error popup using jWindow component")
		for error in errors:
			## TO DO: Log errors to SQL database for future reference. Include hostname
			logger.warn("Error title: %s, Message: %s, Exception: %s" % (error.title, error.message, error.exception))
		# end for
	# end if

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 12, 2022, 3:18pm UTC](https://forum.inductiveautomation.com/t/vision-closing-error-box-popup-via-scripting/62902/5 "2022-08-12T15:18:17Z")

</div>

Versioned Javadocs are linked on our SDK examples Github page:

> **[Javadocs & Notable API Changes ·...](https://github.com/inductiveautomation/ignition-sdk-examples/wiki/Javadocs-&-Notable-Api-Changes)**
>
> Ignition SDK Example Projects. Contribute to inductiveautomation/ignition-sdk-examples development by creating an account on GitHub.
