# System.perspective.navigate doesn't work on session custom property tag change script

**URL:** <https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [August 24, 2023, 5:34pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348 "2023-08-24T17:34:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachary.roisum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zachary.roisum/32/42809_2.png) [@zachary.roisum](https://forum.inductiveautomation.com/u/zachary.roisum)\
**Post date:** [August 24, 2023, 5:34pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/1 "2023-08-24T17:34:19Z")

</div>

I am attempting to use the session prperty lastActivity to drive a session custom property that acts as an inactivity timer. That expression binding is working well and when displayed on a page the number is accurate. The expression fails to evaluate in designer but does evaluate correctly on any other session.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f7ec11195cf3532a1c2adddb640b7088b78497e6.png)

I then wanted to add a change script to this new custom property to navigate to the home page but that does not work. The script works when used on a button.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd9105396c18dd6fff656839505602d5bdc667f3.png)

Since the error mentioned no perspective page attached to the thread, I attempted to also use pageId='/' as an optional parameter to system.perspective.navigate, but although that resolved the error on clicking save/apply it did not actually navigate to the page '/' as I was hoping. This syntax does not work on a button either. The manual page doesn't have an example of the optional parameter pageId, I'm looking to the community for help on formatting that correctly.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19a0cedeb0063db8ff722ecad065d81a145186f2.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 24, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/2 "2023-08-24T18:25:31Z")

</div>

You're getting caught up in a common Designer vs. Session context issue.

In the Designer, there are no pages; the concept doesn't exist. But some pieces are dependent on a reference to `pageId` not being `null`, so we provide the View name as a placeholder within the Designer. IN a running Session, that `pageId` value is actually a unique value generated as each tab is opened.

Now, the _Session_ has no idea which page of the potentially multiple you could have open that you want to navigate, so you'll have to manage that yourself.

- Loop over every page of the session by making use of `system.perspective.getSessionInfo()` and filter the results based on the `sessionId` of this Session.

```auto
if currentValue.value > 2:
    all_sessions = system.perspective.getSessionInfo()
    for session in all_sessions:
        if session.id == self.session.props.id:
            page_ids = session.pageIds
            for page_id in page_ids:
                system.perspective.navigate(page="/", sessionId=session.id, pageId=page_id)

```

You might also be able to do something like this:

```auto
if currentValue.value > 2:
    for page in self.pages:
        system.perspective.navigate(page="/", sessionId=self.id, pageId=page.id)

```

---

<div class="post-metadata">

**Author:** ![zachary.roisum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zachary.roisum/32/42809_2.png) [@zachary.roisum](https://forum.inductiveautomation.com/u/zachary.roisum)\
**Post date:** [August 25, 2023, 8:29pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/3 "2023-08-25T20:29:15Z")

</div>

Thanks! The first solution you proposed worked well for my application.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [May 8, 2024, 12:54am UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/4 "2024-05-08T00:54:04Z")

</div>

Is it possible to use your first code example on a Session `Startup` event?

I get a log error stating that `global name 'self' is not defined`. So I changed it to `session.props.id` and got `object has no attribute 'props'`.

Is there another way? thanks

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 8, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/5 "2024-05-08T14:42:29Z")

</div>

It would probably work with some changes, but you're going to run into name collisions just trying to use it like it is because the supplied kwarg is `session`.

```python
if currentValue.value > 2:
    all_sessions = system.perspective.getSessionInfo()
    for user_session in all_sessions:
        if user_session.id == session.props.id:
            page_ids = user_session.pageIds
            for page_id in page_ids:
                system.perspective.navigate(page="/", sessionId=user_session.id, pageId=page_id)

```

---

<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:** [June 24, 2024, 5:22pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/6 "2024-06-24T17:22:09Z")

</div>

Split this topic on June 24, 2024, 5:22pm UTC

18 posts were merged into an existing topic: [Open View when Tag Changed](https://forum.inductiveautomation.com/t/open-view-when-tag-changed/92252/9)

---

<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:** [June 24, 2024, 6:19pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/12 "2024-06-24T18:19:28Z")

</div>

Split this topic on June 24, 2024, 6:19pm UTC

2 posts were merged into an existing topic: [Open View when Tag Changed](https://forum.inductiveautomation.com/t/open-view-when-tag-changed/92252/29)

---

<div class="post-metadata">

**Author:** ![athenabelle](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@athenabelle](https://forum.inductiveautomation.com/u/athenabelle)\
**Post date:** [June 29, 2026, 1:59pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/13 "2026-06-29T13:59:12Z")

</div>

I am having a similar issue and I fell upon this page. I have a system.perspective.navigateBack() on a menu tree but it would not sync up with session customs. Not sure how I should go about it right now.

Here is the code I have for reference (which is in onItemClicked action):

Machine\_6802 is the fall back if anything happens or fails (which that is the case right now)

```python
def runAction(self, event):
    if event.path and event.path[0] == 0:
        if self.session.custom.previousMachine:
            self.session.custom.selectedMachine = self.session.custom.previousMachine
        else:
            self.session.custom.selectedMachine = "Machine_6802"

        system.perspective.navigateBack()

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 29, 2026, 2:54pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/14 "2026-06-29T14:54:14Z")

</div>

Having the script is nice, but only if we know what isn't working for you with regard to your expectations. Under what scenario does your script not do what you want?

---

<div class="post-metadata">

**Author:** ![athenabelle](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@athenabelle](https://forum.inductiveautomation.com/u/athenabelle)\
**Post date:** [June 29, 2026, 3:15pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/15 "2026-06-29T15:15:48Z")

</div>

It goes back to the previous page but it wouldn't sync up with session customs.

Session customs is bind with a drop-down box bidirectionally, which makes the entire view change based on the machine selected.

If item clicked, it would go back to Machine\_6802 despite other machines being clicked

Clearer example:  
Machine\_1 is on the page, I clicked on Machine\_7. I clicked the button that is supposed to navigate me back to the previous screen (Machine\_1) but it shows me Machine\_6802 instead.

Going back to the page (such as switching a view page from Summary to Tracker, etc.) is fine but just the session custom is not syncing up.

Let me know if you need anymore clarification.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 29, 2026, 4:03pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/16 "2026-06-29T16:03:47Z")

</div>

That tells me you either have `"Machine_6802"` as the default value of that `self.session.custom.previousMachine` prop, or `self.session.custom.previousMachine`is evaluating as false-y.

Or `self.session.custom.previousMachine`is `"Machine_6802" and you're never updating it.`

---

<div class="post-metadata">

**Author:** ![athenabelle](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@athenabelle](https://forum.inductiveautomation.com/u/athenabelle)\
**Post date:** [June 29, 2026, 4:05pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/17 "2026-06-29T16:05:51Z")

</div>

`self.session.custom.previousMachine` is empty even when that code is executed (after the item is clicked on the menu tree)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 29, 2026, 4:09pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/18 "2026-06-29T16:09:40Z")

</div>

> [@athenabelle](#):
>
> `self.session.custom.previousMachine` is empty even when that code is executed

So then you'd always enter the `else` statement and therefore always use the hard-coded value. You need to update that `previousMachine` prop anytime a user clicks a machine. Also, it will only ever hold one value, so you won't be able to go back through a historical list; you're limited to going back to the singular most recent machine.

---

<div class="post-metadata">

**Author:** ![athenabelle](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@athenabelle](https://forum.inductiveautomation.com/u/athenabelle)\
**Post date:** [June 29, 2026, 4:11pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/19 "2026-06-29T16:11:24Z")

</div>

Would it be helpful changing that to an array/list? That's what I have it on

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 29, 2026, 4:12pm UTC](https://forum.inductiveautomation.com/t/system-perspective-navigate-doesnt-work-on-session-custom-property-tag-change-script/78348/20 "2026-06-29T16:12:47Z")

</div>

Potentially, but then you're looking at tracking an index across that list. User navigation history is messy. I can't recommend a great way to manage their history - all I can do is point out that the script you supplied won't manage it.
