OPC tag to open a popup window in perspective

Hi

I’m just started to learn how to program in ignition perspective, so I apologize for the silly questions. I’m trying to open a popup window when a tag (from opc ua , but for testing Im using a bool memory ) changes status from off to on. I know there is a lot of topics related to this but all that I tried does not work and never opens a popup window.

I’m using ignition edge perspective.!.

I have read, the best option is to bind a property in my view to a tag and then set up a change script on that property to trigger the popup.

image

image405×144 7.84 KB

image

image1044×333 28.5 KB

image

image383×383 17.4 KB

image

image320×532 17.4 KB

My script:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value:
		system.perspective.openPopup("_PopUp_Test", "PopUp_Test")


I appreciate any help.

Thanks

I'm just checking that you're aware that Designer's limited browser emulation doesn't support navigation in general, and doesn't support popups in particular.

Have you tested it by running the view in a browser?

Tips:

  • You can also put a system.perspective.print() statement into your script. This will output to Designer's Console (at least you'll know the script ran in Designer - even if the popup doesn't).
  • It will also output to the browser's Developer Tools console. Hit F12 and find the Console tab.
2 Likes

Thank you for your reply.

Yes , I‘m awere of that and I’m running the view in a browser.

I’m using a trial version at the moment , do you think this can be an issue?.

Trial versions are fully functional.

Are you sure this is correct view path?

View path looks correct. As an aside, I do prefer to use keyword args instead of just relying on the index of them. They help to know exactly what you're passing into the function without relying on your memory or having to look it up each time, and they also help others avoid the same when you’re asking for help (I had to look up the order of args myself, despite having used it countless times).

In addition to adding a print statement as @Transistor suggested, I sometimes also add a label which binds to the custom prop to verify its actually showing the right value

It looks like it can be in parent folder though. Based on my preliminary investigation.

Where is your mypopup custom property located? If it is inside your popup's view and you are trying to open the popup from a different view in your browser, it will not work. Try placing mypopup in a session custom property. That way, mypopup will be available in your browser session regardless of which views are currently open.

Edit: See Phil and Cody's replies below for the recommended approach.

No, a change script attached to a session custom prop only has session scope, and cannot open a popup. It needs to be a view custom prop. This is best placed on a shared dock view that is always present.

3 Likes

Well… Sort of. Even though it’s limited to the session scope, it could still open a popup on a given page by looping over the pages known to be a part of the session.

See this solution I posted for a similar navigation attempt.

Even with that solution, moving this to some always-present bit of UI is indeed the recommended approach.

2 Likes

That was actually the problem. My custom property was located inside my popup window. I moved the custom property to the “MainPage” view and it works fine. But the problem them was to open the popup from other views because the custom property I created was associated to the “MainPage”. So I found here in the forum a script that works very well. So, problem solved. Thanks very much for all the members help, much appreciated.

Bellow some print screens showing what I did for future reference.

Script:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    popupId = "_PopUp_Test"
    viewPath = "PopUp_Test"  # insert your view path here
    logger = system.util.getLogger("POPUP")
    sessions = system.perspective.getSessionInfo()
    for session in sessions:
        for pageId in session.pageIds:
            logger.info("{0} | {1}".format(session.id, pageId))
            if session.userAgent != "<designer>":
                if currentValue.value:
                    system.perspective.openPopup(popupId, viewPath, sessionId=session.id, pageId=pageId)
                else:
                    # note no viewPath arg
                    system.perspective.closePopup(popupId, sessionId=session.id, pageId=pageId)


With the script above the popup window can be seen in all the different views of the project when the bool00 changes to true and close the popup when the bool00 changes to false.

It should be on one of your shared docks, not on a (non-docked) page. It actually doesn't matter which dock as theyre always in the DOM, they just get pulled in/out based on your config, but logically and for the sanity of others, I choose the main header/navigational dock