Script help: passing screen name as variable of system.nav.openWindowInstance()

I don’t understand what is happening:

  1. The script created when navigation - open - pass parameters is selected:
# This script was generated automatically by the navigation
# script builder. You may modify this script, but if you do,
# you will not be able to use the navigation builder to update
# this script without overwriting your changes.

param1 = event.source.path2

window = system.nav.openWindowInstance('Common/vfdPowerFlex525', {'vfdTagPathAndName' : param1})
system.nav.centerWindow(window)
  1. I want to open different popup windows based on a value, so I tried making the first parameter a variable that contains the name of the desired popup window:
param1 = event.source.path2

vfdpopupwin = "'Common/" + event.source.parent.getComponent('vfdpopupname').text +"'"

window = system.nav.openWindowInstance(vfdpopupwin, {'vfdTagPathAndName' : param1})
system.nav.centerWindow(window)

and this gives me the error:

17:58:48.928 [AWT-EventQueue-2] ERROR com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter - <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>VFD button</b></code>.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<event:actionPerformed>", line 15, in <module>
ValueError: Window 'Common/vfdPowerFlex525' does not exist.
  1. Can anyone help me understand what is happening and how to accomplish this (simple) task. I think I might need to designate that I want the value of the variable evaluated, but I’m not sure that is the problem.

kb5won

your string variable does not need to be in quotes, its already a string

try the following

param1 = event.source.path2

vfdpopupwin = "Common/" + event.source.parent.getComponent('vfdpopupname').text

window = system.nav.openWindowInstance(vfdpopupwin, {'vfdTagPathAndName' : param1})
system.nav.centerWindow(window)

Chris

2 Likes

Thank you Chris! I have mixed emotions about how simple that was, but I appreciate your help. It works like I want now.

-Brian

Did you have to define 'vfdpopupwin' anywhere else? I can't seem to replicate this

The OP's example is using variable names he decided on, and a window parameter name he decided on. Whatever names you use are up to you. Provide more information about your setup, what you're trying to do, and we'll be able to help you better.