Navigation using a Momentary Button issue

No. It sounds like the PLC writes nothing to the tag when a login fails. The best solution to this may be changing how the PLC writes to the tag as adamaustin has suggested.

You can use the script below. This script will check the value of event.source.currentUserLevel 2 seconds after the button is pressed. You may want to increase or decrease the delay.

def func(event=event):
	if event.source.currentUserLevel > 0:
		system.nav.swapTo("Window")
	else:
		system.gui.warningBox("Login Failed")		

if event.propertyName == "controlValue":
	if event.newValue == 1:
		system.util.invokeLater(func,2000)

[quote=“nmudge”]No. It sounds like the PLC writes nothing to the tag when a login fails. The best solution to this may be changing how the PLC writes to the tag as adamaustin has suggested.

You can use the script below. This script will check the value of event.source.currentUserLevel 2 seconds after the button is pressed. You may want to increase or decrease the delay.

[code]
def func(event=event):
if event.source.currentUserLevel > 0:
system.nav.swapTo(“Window”)
else:
system.gui.warningBox(“Login Failed”)

if event.propertyName == “controlValue”:
if event.newValue == 1:
system.util.invokeLater(func,2000)
[/code][/quote]

It says “Error running function from fpmi.system.invokeLater”. The error details:
“NameError:Global name ‘system’ is not defined”

Try this:

def func(event=event):
   import system
   if event.source.currentUserLevel > 0:
      system.nav.swapTo("Window")
   else:
      system.gui.warningBox("Login Failed")      

if event.propertyName == "controlValue":
   if event.newValue == 1:
      system.util.invokeLater(func,2000)

[quote=“nmudge”]Try this:

[code]
def func(event=event):
import system
if event.source.currentUserLevel > 0:
system.nav.swapTo(“Window”)
else:
system.gui.warningBox(“Login Failed”)

if event.propertyName == “controlValue”:
if event.newValue == 1:
system.util.invokeLater(func,2000)
[/code][/quote]

Whoa! That worked! Although when I press the the Logout PB on the same page, the warningBox reappears. But the Login button works to perfection!!