# Can't reopen the popup after clicking the OK button to close it

**URL:** <https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 23, 2025, 6:33pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688 "2025-06-23T18:33:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimu9205](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kimu9205](https://forum.inductiveautomation.com/u/kimu9205)\
**Post date:** [June 23, 2025, 6:33pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688/1 "2025-06-23T18:33:36Z")

</div>

I created a popup that appears when I click the event button. For some reason, after I click the OK button in the popup to close it, I can't reopen it. I’ve created other popup buttons using the same script, and they work fine—only this one doesn't reopen.

This is the script for Event button.

```python

def runAction(self, event):

	import system
	from java.text import SimpleDateFormat
	
	# Logger setup
	logger = system.util.getLogger("EventPopupButton")
	
	try:
	    # Get parameters
	    catid = self.parent.parent.parent.getChild("FlexContainer")\
	        .getChild("TabContainer")\
	        .getChild("EventInfoEmbeddedView").props.params.CatID
	
	    descid = self.view.params.DescID
	    date_raw = self.view.params.Date
	    time_raw = self.view.params.Time
	
	    date_str = str(date_raw)
	    time_str = str(time_raw)
	    datetime_str = date_str + " " + time_str
	
	    logger.infof("catid=%s, descid=%s, date_str=%s, time_str=%s", catid, descid, date_str, time_str)
	
	    # Convert to ISO format
	    input_format = SimpleDateFormat("yyyy-MM-dd h:mm a")
	    output_format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
	
	    try:
	    	date_obj = input_format.parse(datetime_str)
	        iso_date = output_format.format(date_obj)
	        logger.infof("ISO datetime = %s", iso_date)
	    except Exception as dt_err:
	        logger.error("Date/time parse failed: {} - datetime_str = '{}'".format(str(dt_err), datetime_str))
	        iso_date = "" # fallback to blank or default

	    # Close popup if already open
	    try:
	        system.perspective.closePopup("EventDescPopupID")
	    except:
	        logger.warn("Popup wasn't open or failed to close. Continuing...")
	
	    # Open popup with parameters
	    system.perspective.openPopup(
	        id="EventDescPopupID",
	        view="Templates/Popups/Event Description",
	        params={
	            'Date': date_str,
	            'Time': time_str,
	            'CatID': catid,
	            'DescID': descid,
		            'ISO_DateTime': iso_date
        },
	        title="Event Description",
	        modal=False,
	        draggable=True,
	        showCloseIcon=True,
	        position={"left": 300, "top": 150}
	    )
		
	    logger.info("Popup opened successfully.")
	
	    # Send session-scoped message
	    system.perspective.sendMessage("CatEventDescPopup", payload={
	        "CatID": catid,
	        "DescID": descid,
	        "Date": date_str,
	        "Time": time_str
	    }, scope="session")
	
	    logger.info("Message sent to CatEventDescPopup.")
	
	except Exception as e:
	    import traceback
	    logger.error("Popup failed:\n" + traceback.format_exc())

```

This one is for ok button.

```python

def runAction(self, event):

	from java.text import SimpleDateFormat
	from java.util import Date
	
	
	# Get the current date and time
	now = Date()
	
	# Define the ISO 8601 format
	iso_format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
	
	# Convert the date to ISO 8601 format
	iso_date = iso_format.format(now)
	
	logger = system.util.getLogger("EventInfoEdit")
	catid = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("CategoryContainer").getChild("Dropdown").props.value
	descid = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("DESCContainer").getChild("Dropdown").props.value
	date = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("DateTimeContainer").getChild("DateInput").props.value
	iso_datetime = date

	datetime = iso_format.format(date)
	logger.infof("DateTime: %s", datetime)
	system.perspective.sendMessage("RefreshEventInfo", payload= {"CatID": catid, "DescID": descid, "Date": date, "DateTime":datetime}, scope = "session")
	
	system.perspective.closePopup("EventDescPopupID")

```

---

<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:** [June 23, 2025, 6:49pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688/2 "2025-06-23T18:49:47Z")

</div>

Are there any errors, in your gateway or browser console logs?

As a secondary point; don't trust LLMs (I'm assuming) to give you useful help with Ignition.  
This entire block:

> [@kimu9205](#):
>
> ```python
> from java.text import SimpleDateFormat
> from java.util import Date
> 	
> 	
> # Get the current date and time
> now = Date()
> 	
> # Define the ISO 8601 format
> iso_format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
> 	
> # Convert the date to ISO 8601 format
> iso_date = iso_format.format(now)
> 
> ```

Is **exactly** equivalent to these two built in system functions: `iso_date = system.date.format(system.date.now(), "yyyy-MM-dd'T'HH:mm:ss")`

Similar advice applies to your first code snippet. Until/unless you know better, if you're reaching to an import from Python _or_ Java, you're doing it wrong.

---

<div class="post-metadata">

**Author:** ![kimu9205](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kimu9205](https://forum.inductiveautomation.com/u/kimu9205)\
**Post date:** [June 23, 2025, 7:44pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688/3 "2025-06-23T19:44:46Z")

</div>

Thank you for the reply! I'm pretty new to Ignition. I do see an error in the browser console logs, but I don't think it's something that would affect what I'm working on right now.

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

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 23, 2025, 7:53pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688/4 "2025-06-23T19:53:15Z")

</div>

Post stack traces as pre-formatted text, not images, see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). Just copy the stack trace as a whole and put it in the pre-formatted text block.

Neither of the scripts you gave us have 265 lines present, so its likely the source is elsewhere (maybe your message handler?). Looking at the error, it appears you forgot to close a pair of parentheses somewhere.

Additionally, you should NOT be importing anything within a function definition. You should never have to `import system`, its always available in all scripting contexts.

Also, the logger methods also accept a trace object as an additional argument. Don't stringify the traceback you get from your exception clauses. Example:

```python
except Exception as dt_err:
	        logger.error("Date/time parse failed: {} - datetime_str = '{}'".format(str(dt_err), datetime_str))

```

Should be

```python
except Exception as dt_err:
	        logger.errorf("Date/time parse failed for datetime_str '%s'", datetime_str, dt_err)

```

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 23, 2025, 8:02pm UTC](https://forum.inductiveautomation.com/t/cant-reopen-the-popup-after-clicking-the-ok-button-to-close-it/107688/5 "2025-06-23T20:02:18Z")

</div>

An additional housekeeping nitpick:

> [@kimu9205](#):
>
> ```python
> catid = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("CategoryContainer").getChild("Dropdown").props.value
> descid = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("DESCContainer").getChild("Dropdown").props.value
> date = self.parent.parent.parent.getChild("FlexContainer_0").getChild("FlexContainer").getChild("DateTimeContainer").getChild("DateInput").props.value
> 	
> 
> ```

The values for all these dropdown components should be bidirectionally bound to custom properties on the view or the view root container.

It makes it extremelty robust and makes access much simpler. Your access to the item is now `catId = self.view.custom.catId`, and will work no matter where the button is in the view container hierarchy.
