Perspective Navigate on Gateway Even Script Tag Event

Hi IA community,

I am trying to use the system.perspective.navigate() function to navigate to various views based on certain tag values following a tag change event on the same tag. I am attempting to do this in a gateway event script. My understanding is that I need to get the session Id and page Id's.

To test whether I am actually able to get the session and page Id's, I am writing those values to tags. I see content in my 'sessionId' tag, but not in my 'pageId' tag. Unfortunately, I don't see much information or examples in the manual that align with what I am trying to accomplish. Nor do I see much in the forums.

Can someone please advise what I could be doing wrong here? Thank you in advance for any help anyone could provide! My code is below.

#Get session info for the Digital Signage project
sessionInfo = system.perspective.getSessionInfo(projectFilter = 'Digital_Signage')

#If step value is 30, then navigate to the break screen
if newValue.getValue() == 30:
	system.perspective.navigate(view = '1st Shift Break 1 Time Screen', sessionId = sessionInfo['id'], pageId = sessionInfo['pageIds'])
	system.perspective.refresh(sessionId = sessionInfo['id'], pageId = sessionInfo['pageIds'])

#Write session ID and page ID's to their respective tags
system.tag.writeBlocking('[Digital Signage]sessionID', sessionId)
system.tag.writeBlocking('[Digital Signage]PageID', pageId)

A couple of pointers:

to navigate to various screens pages or views ...

session and page Id's, I am writing those values to tags.

Every open client will be trying to do the same. It's not a good idea.

Where are you running the script you posted? In a tag change or in the Perspective application?

Hi Transistor, the script is in the gateway event script. The event type is a tag change.

It is much better and more consistent (and easier to debug down the road) if you invert the control flow.
Instead of a tag changing, and having to "reach out" to a particular session (or all sessions) -
In each project where you want to monitor this tag, add a session custom property. Bind it to the tag. Add a property change script with whatever filtering logic (i.e. when value == 30, and/or which sessions to apply this logic to).
Then you can directly run whatever Perspective navigation actions you want, because you're still in the "context" of the session.

5 Likes