# Perspective Navigate on Gateway Even Script Tag Event

**URL:** <https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782>\
**Category:** Ignition\
**Tags:** python, perspective, scripting, ignition81\
**Created:** [May 1, 2024, 6:16pm UTC](https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782 "2024-05-01T18:16:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Motts](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@Brian\_Motts](https://forum.inductiveautomation.com/u/Brian_Motts)\
**Post date:** [May 1, 2024, 6:16pm UTC](https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782/1 "2024-05-01T18:16:00Z")

</div>

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.

```python
#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)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 1, 2024, 6:24pm UTC](https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782/2 "2024-05-01T18:24:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Brian\_Motts](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@Brian\_Motts](https://forum.inductiveautomation.com/u/Brian_Motts)\
**Post date:** [May 1, 2024, 6:28pm UTC](https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782/3 "2024-05-01T18:28:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 1, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/perspective-navigate-on-gateway-even-script-tag-event/89782/4 "2024-05-01T18:31:15Z")

</div>

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.
