I have a security check script that’s used across 27 windows (around 54 times) in my project.
Now I need to integrate an E-Signature popup into the same script.
When a user performs an action, the E-Sign window opens, and after the user clicks OK, it validates the credentials and writes a tag to True.
The problem is — my main script continues execution immediately after opening the E-Sign window, instead of waiting for the user’s response.
We tried multiple approaches like:
while loop and system.util.ivokeLater()
Background thread to monitor a tag
But nothing worked reliably — the script either hangs or runs ahead before the popup completes.
Is there any way in Ignition Vision to pause the script until the popup returns a value (like tag = True or window closed), and then continue execution without freezing the client?
If you don’t mind stopping the EDT and don’t mind the aesthetics of system.gui, you can use system.gui.inputBox/passwordBox to get the user credentials then and there instead of your custom popup.
Otherwise I don’t see any way except for doing the first bit of the script, opening your popup, then on sucessful login of inside the popup, sending a message/writing to a tag/otherwise signalling the start the second bit of the script to run.
You could have your poppup reach into the parent window to change a root container property to trigger the second bit of the script as well via a property change. But regardless you will need to split up your scipt. I would really recommend not trying to “wait” inside the one script. It’s an anti-pattern.
Another option is when you have to wait for feedback on these kinds of things, you can swap to a state machine where a timer or tag change script, checks the current state, then acts appropriately.
You cannot wait in the script. You need to split the script into two parts:
The part up to and including the system.nav.openWindow(), and
a part attached to your OK button in the popup.
Presumably, there is data in the first part you need in the 2nd part. Pass those as window parameters into the popup (root container custom props). That makes them available for the 2nd part.
If any of that data is not suitable for storage in a container custom property, use Swing's .putClientProperty() method on the window (right after opening) to store arbitrary jython data. In the OK button script, you can use .getClientProperty() to retrieve it.