Navigation by Dropdown

Hi, I’m new to Ignition. I’m am struggling to navigate to a specific screen when the user click chooses an option in Drop down. My dropdown has two options: siteA and siteB. I already assigned value 0 for siteA and value 1 for siteB. I have written a script and bound it on value of the dropdown. But it did not work.
Here is my script that I wrote:

def transform(self, value, quality, timestamp):
	if value:
	   if value == 0:
	      system.perspective.navigate("/siteA")
	   elif value == 1:
	      system.perspective.navigate("/siteB")
	return value

Actually, I was not confident with this script. I felt it should return void instead of returning the value.
I also tried to configure event for the click event, but it still did not work.

Thank you so much for your time.

1 Like

You probably don’t want to use a transform. Instead, add the sites you want to navigate to as the ‘value’ property of your dropdown options: Perspective - Dropdown - Ignition User Manual 8.1 - Ignition Documentation.
Then right click the dropdown and ‘Configure Scripts’. Find the onActionPerformed event and add a Script action to it:
Perspective Event Types Reference - Ignition User Manual 8.0 - Ignition Documentation

In that script, read the selected value and call navigate:

if self.props.value:
    system.perspective.navigate(self.props.value)
2 Likes

Yeah, it worked. Thank you for your help!

Worked for me as well