You’d be better off reading the actual state in the first window and setting the actual value via the DB/PLC in the second. This is much more meaningful than setting the first window variable from the popup window. Obviously if it goes all the way through the PLC it could represent the true state. If it goes through the database then at least all your concurrent clients would be on the same page.
I’m going to use user selectable valves for this example. Parameter passing wouldn’t be necessary with only one valve.
Create a selectedValve dynamic property in the main window, allowing the user to choose a valve. You have many ways of doing this.
The dynamic variable, valveState, in the main window represents the actual state of the selected valve. This should be periodically polling (bound to) the SQL database.
Clicking on your object should open the popup window, passing selectedValve to tell the window which valve to open/close.
Have the open and close buttons in the popup window write to the SQL database for selectedValve. It’s better practice to write to a “request to open” bit and read from an “open status” bit rather than using a single “open”. You can read from and write to the same bit for a demo system or if your valve doesn’t distinguish between the states.
Do you still need a code example? I think you know how to do all the steps.
note - if you’re still interested in changing a dynamic variable in another window there are a couple of options. The hard way (shown below) uses Jython to “drill down” the object model to set the variable. The “easy way” is to do it exactly like you did with the popup window. Use fpmi.gui.openWindow() and pass valveState, which should be on the Root Container. openWindow sets focus if the window is already open. If your variable isn’t on the Root Container you can bind it to a dynamic variable that is. If valveState is set to update the SQL database on a change the value will get written back to the DB/PLC. You would probably then want to close the popup window with the next line of Jython code.
“hard way” example without error handling
window = fpmi.gui.getWindow('main')
SQLTags will allow you to use global dynamic variables. In this case I would still set it up as described above.