# Close window

**URL:** <https://forum.inductiveautomation.com/t/close-window/6130>\
**Category:** General Discussion\
**Created:** [April 1, 2013, 5:15pm UTC](https://forum.inductiveautomation.com/t/close-window/6130 "2013-04-01T17:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [April 1, 2013, 5:15pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/1 "2013-04-01T17:15:31Z")

</div>

I am currently a system that has a main window (Full screen) and a number of windows that pop up as an overlay for the operator to enter or select items. I have a cancel button that will close this window using ‘system. nav.closeParentWindow(event)’ works fine of cousre. What I cannot get to happen is when the opertor selects the enter button I run a number of app’s in the script module and want to close the window at the end of the script. Unable to get any of the closeWindow commands to work, what am I missing?

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 1, 2013, 5:19pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/2 "2013-04-01T17:19:29Z")

</div>

You should be able to use the same system.nav.closeParentWindow(event) function call. I bet your script is not even getting to that line. Are you getting an error? Can you post the script here?

---

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [April 1, 2013, 5:57pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/3 "2013-04-01T17:57:22Z")

</div>

Hi Travis,

The code is getting to that point and beyond. I am not getting any errors. I had even set ip up to tell me if there was a problem with the window and it wpould come up as window not open.

[size=85]  
#\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*#

# Routine Definitions

#\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*#

# 1 - Box count

# 2 - Bag Count

def record(routine, lotNum):  
import system  
import app  
from java.util import Date  
#\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*#

# Variable Declaration Section

#\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*#

# lotNumber = ‘’

# date = ‘’

```
operatorName = system.tag.getTagValue('[Client]Tracking/Current_Operator')
operatorId = system.tag.getTagValue('[Client]Tracking/Current_Operator_ID')
ingName = system.tag.getTagValue('[Client]Tracking/Selected_Ing')
qtyUsed = system.tag.getTagValue('[Client]Tracking/Select_Box_Count')
balanceQty = system.tag.getTagValue('[Client]Tracking/Balance_Qty')
recordId = system.tag.getTagValue('[Client]Tracking/Lot_RecordId')

now = Date()
ts = system.db.dateFormat(now, "HH:mm:ss")	#database entry generation time
ds = system.db.dateFormat(now, "yyyy-MM-dd")	#database entry generation date
date = ds + " " + ts

if routine == 1:	#1 - Box count
	
	system.db.runUpdateQuery("INSERT INTO Used_Lot_Numbers (Lot_Number, Date, Operator, Operator_ID, Ing_Name, Qty_Used, Qty_Balance) VALUES ( %d, '%s' , '%s', %d, '%s', %d, %d);" % (lotNum, date, operatorName, operatorId, ingName, qtyUsed, balanceQty), 'Mill_Tracking')
	system.db.runUpdateQuery("UPDATE Lot_Numbers SET Qty_Balance = %d WHERE idLot = %d ;" % (balanceQty, recordId), 'Mill_Tracking')	
	system.db.runUpdateQuery("UPDATE Lot_Numbers SET Date_Modified = '%s' WHERE idLot = %d ;" % (date, recordId), 'Mill_Tracking')	

system.nav.closeParentWindow('Popup_Box_Count')
system.tag.writeToTag('[Client]Tracking/Select_Box_Count',0)
system.tag.writeToTag('[Client]Tracking/Lot_Num_OK',0)
system.tag.writeToTag('[Client]Tracking/Select_Lockout',0)
system.tag.writeToTag('[Client]Tracking/Selected_Lot_Num',0)	
app.Ingredient_Select_Control.Control(0)

```

[/size][/color]

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 1, 2013, 6:14pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/4 "2013-04-01T18:14:24Z")

</div>

Is “Popup\_Box\_Count” the correct path to your window? In the designer right click on the window and select copy path. Paste it somewhere to make sure. When a window is in a folder you would get a path like this:

Folder/Popup\_Box\_Count

---

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [April 1, 2013, 6:31pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/5 "2013-04-01T18:31:39Z")

</div>

The window is not in a folder. It is a branch of windows in the designer. The copy and paste only showed the ‘PopUp\_Box\_Count’

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 1, 2013, 7:16pm UTC](https://forum.inductiveautomation.com/t/close-window/6130/6 "2013-04-01T19:16:17Z")

</div>

Oh, I made a rookie mistake. You are using the close parent window function which only works when passing the event object in. You have to use system.nav.closeWindow when you specify a window path:`system.nav.closeWindow('Popup_Box_Count')`That will work!
