# Dynamic go back button Perspective

**URL:** <https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 1, 2020, 11:40am UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348 "2020-05-01T11:40:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrijkers](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@rrijkers](https://forum.inductiveautomation.com/u/rrijkers)\
**Post date:** [May 1, 2020, 11:40am UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/1 "2020-05-01T11:40:29Z")

</div>

Hi,

I am new to Ignition and the scripting in this program.  
I have a “go back” button in my dockview and i want to make it go back to the previous view.  
All my views are in the same page.  
So i know what view i want to go back from any view i am in, but because it is in the dockview it has to be dynamic.  
I have tried different scripting event, but cant get it to work.  
My quenstion: is there a way to make it dynamic.

Ik have to do the same with a text field for showing my status per machine.

Thanks a lot in advance!

Ronnie

---

<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 1, 2020, 3:22pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/2 "2020-05-01T15:22:10Z")

</div>

Using Perspective to “go back” to different Views instead of using the browser to go back to different Pages is going to be a fairly complex process. I’ve thought a bit about how to set this up in the past and there are a few ways to do this:

1. You could query a database which is set up to have a column like currentViewPath and a column like backViewPath, and then when the button is pressed query for the backViewPath based on your current View’s path and navigate to the result.

```auto
# If you don't have a default database for the project, you'll need to include an argument for that
# This also assumes a table named "ViewNavigationLinking"
viewPath = system.db.runQuery("select backViewPath from ViewNavigationLinking where currentViewPath={0}".format(self.page.props.primaryView))
system.perspective.navigate(view=viewPath)

```

1. You could have a tag which operates the same way.

```auto
viewPath = system.tag.readBlocking([self.page.props.primaryView])[0]
system.perspective.navigate(view=viewPath)

```

1. You could have a custom property on EVERY View which declares the path of the View to go back to from this View. This would then also require a configured message listener on the View root listening at the Page or Session scope as well as a broadcast from the button on that same scope.

Button script:

```auto
system.perspective.sendMessage('VIEWGOBACK', scope='page')

```

Configure a Message Handler on the root of every View with the handler name of “VIEWGOBACK” and the following script:

```auto
system.perspective.navigate(view=self.custom.backViewPath)

```

---

<div class="post-metadata">

**Author:** ![rrijkers](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@rrijkers](https://forum.inductiveautomation.com/u/rrijkers)\
**Post date:** [July 1, 2020, 6:30am UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/3 "2020-07-01T06:30:12Z")

</div>

Hi cmallonee,

I am sorry for the late reaction.  
I am planning to add a parameter on every view, so i know when it is open.  
I want to make labels visible in the dockview in certain views, i want to use this parameter also for the navigation, but i cant figure out how to make a parameter true when a view is open.

I hope you can help me.

Thank you in advance.

With kind regards,

Ronnie Rijkers

---

<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:** [July 1, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/4 "2020-07-01T14:46:29Z")

</div>

> [@rrijkers](#):
>
> but i cant figure out how to make a parameter true when a view is open.

1. Create the custom property with the desired key (`custom.myKey`).
2. Set the value to `false`.
3. Create a View onStartup Event, and associate a Script Action to the Event.
4. Supply the following code for the script: `self.custom.myKey = True` (note the case difference in "true").

BUT... This is not going to do what you want, because you have no way to refer to this property from outside the View. You could move the relevant value to a `param`, but you still have no way to know WHICH View you're looking at.

---

<div class="post-metadata">

**Author:** ![rrijkers](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@rrijkers](https://forum.inductiveautomation.com/u/rrijkers)\
**Post date:** [July 2, 2020, 10:51am UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/5 "2020-07-02T10:51:50Z")

</div>

cmallonee,

I am going to make tags in the tagbrowser by each view.  
This way i know which view is open. I tried by making the myKey true on view startup and false on view shutdown. But this don`t seem to work. This way i thought to make the right tag high, but it seems like the shutdown script don`t run when i leave the view, is this possible?

Other question, what is the different between the True and “true” in the script.

Thankyou

---

<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:** [July 2, 2020, 1:23pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/6 "2020-07-02T13:23:08Z")

</div>

> [@rrijkers](#):
>
> But this don't seem to work.

I just verified that it should be working, but there are some idiosyncrasies when it comes to View onShutdown Events:

1. You may not use `system.perspective` calls within a View onShutdown Event, because the reference system.perspective calls require to a perspective resource is no longer valid (the View no longer exists, so we have no way to refer to it). So if your onShutdown Event contains any usage of `system.perspective`, you need to remove it.
2. Other `system` calls should work just fine. I just tried `system.tag.writeBlocking()` as part of a View onShutdown Event and had no issue.

> [@rrijkers](#):
>
> what is the different between the True and “true” in the script.

View properties are stored in a .json file, and JSON uses Java variables. Java represents binary truth values with `true` and `false`.

Scripting is done in Jython, which happens to use Python's representation of binary truth values (so `True` and `False`). If you supply a value of `true` or `false` in a script, it will fail to execute at runtime (I believe it throws a NameError). Likewise, if you supply `True` or `False` to the Property Editor, it will interpret that value as a String.

 ![Screen Shot 2020-07-02 at 6.12.24 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b66196e652acd611267663d70a83ed4dcdf6eaf0.png)

---

<div class="post-metadata">

**Author:** ![rrijkers](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@rrijkers](https://forum.inductiveautomation.com/u/rrijkers)\
**Post date:** [July 2, 2020, 1:49pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/7 "2020-07-02T13:49:18Z")

</div>

> [@cmallonee](#):
>
> I just verified that it should be working, but there are some idiosyncrasies when it comes to View onShutdown Events:

I have done it in a different way, i made a session custom parameter `OpenView` where i write in the onStartup view the next code:  
`	self.session.custom.View = "5.2 Cell02_Zone02"` For example.

Now it refresh the parameter each time i open a new view with the name of the view. I have made a binding to a memory tag set to string that holds the name of the view that is currently open.

Now i am searching for a way to fill my memory tag called `PreviousView` that must have 1 delay in changing from views so that i can use this tag to link to my dynamic back button.

Thanks for the help, and i will let you know if i am stuck with the `PreviousView` tag!

---

<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:** [July 2, 2020, 2:00pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/8 "2020-07-02T14:00:28Z")

</div>

The problem with this method is that you will only be able to go back one View. If a user keeps clicking the button, you’ll go back-and-forth between two Views.

---

<div class="post-metadata">

**Author:** ![rrijkers](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@rrijkers](https://forum.inductiveautomation.com/u/rrijkers)\
**Post date:** [July 2, 2020, 2:20pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/9 "2020-07-02T14:20:06Z")

</div>

That hasn’t come to my mind, you are right.  
Then i should have a greater memory of the previous views.  
I have also a navigation where all the screens are visible so there can be navigated in the entire application, the screens don’t have to direct linked so this is going to be a tough one.

The application has a standard layering, so i can make the choice to write a script that goes one layer up the ladder by pressing the button. It works, but ain’t pretty.  
I am going to think about this, and try some of your suggestions.

Thankyou!

---

<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:** [July 2, 2020, 2:25pm UTC](https://forum.inductiveautomation.com/t/dynamic-go-back-button-perspective/34348/10 "2020-07-02T14:25:59Z")

</div>

> [@rrijkers](#):
>
> I have also a navigation where all the screens are visible

This View will wreak absolute havoc with your method as each View will write itself as being open in your property/tag setup. This is why View navigation is a bad idea to try to manage. As part of the View onStartup, you could make a check against the Active Page to see if it's the page you want to apply this logic on:

```auto
if page.props.path = '/some/page/path:
    # write the viewPath of the current View to props/tag

```

but this requires a hard-coded path.
