# Automatically change tab after # seconds in a loop \[Perspective\]

**URL:** <https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [June 25, 2020, 12:37pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027 "2020-06-25T12:37:50Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [June 25, 2020, 12:37pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/1 "2020-06-25T12:37:50Z")

</div>

I am needing to have a timer that will switch to the next tab every 60 seconds, and then continue to loop through the tabs. I am attempting to setup the timer as a Gateway Event, but I feel I am incorrectly calling the tab.

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![KGarner](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgarner/32/15999_2.png) [@KGarner](https://forum.inductiveautomation.com/u/KGarner)\
**Post date:** [June 25, 2020, 1:34pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/2 "2020-06-25T13:34:04Z")

</div>

I might be misunderstanding the question. Are you attempting to control a user’s browser to switch between tabs or do you have a Tab Container that you would like to switch on a timer?

---

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [June 25, 2020, 2:27pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/3 "2020-06-25T14:27:43Z")

</div>

A tab container. For context, the URL will be opened on a TV monitor without any other interactions. Just need the tab container to switch to the next tab every 60 seconds.

---

<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 25, 2020, 2:31pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/4 "2020-06-25T14:31:34Z")

</div>

I would recommend using `system.util.sendMessage()` ([docs](https://docs.inductiveautomation.com/display/DOC80/system.util.sendMessage)) to “broadcast” every 60 seconds. Make sure you’re specifying the session scope. You would then configure a Message Handler on the Tab Container (make sure in the handler that you’re specifying the session scope), and whenever it hears the message, just set TabContainer.props.activeTab to the next available tab. You’ll also want a custom property which defines the maximum known number of tabs so that you can loop back to the first.

Something like this in the handler:

```auto
self.props.activeTab = (self.props.activeTab + 1) % self.custom.total_tabs

```

Update:  
Thinking about this some more, the system.util.sendMessage will only be heard at the SESSION level, so you will need to have three pieces.

1. The Gateway Timer Script should invoke something like `system.util.sendMessage('MyProjectName', 'GATEWAYNEXTTAB',scope='S')`
2. The Project needs to have a Message Handler configured in a SESSION EVENT (in the Menu Toolbar, select Project \> Session Events \> Message) and named ‘GATEWAYNEXTTAB’. This Handler needs to invoke `system.perspective.sendMessage(‘SESSIONNEXTTAB’, scope=‘session’)
3. Then the Tab Container itself needs a Handler with a name of ‘SESSIONNEXTTAB’ set to listen at the session scope, and it needs to invoke the code I presented above.

---

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [June 25, 2020, 3:58pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/5 "2020-06-25T15:58:31Z")

</div>

Really appreciate the followup! I feel am very close, but still missing or incorrectly doing something.

**Gateway Timer Script**

```
    project = 'MyProjectName'
    messageHandler = 'GatewayNextTab'
    scope = 'S'
    system.util.sendMessage(project, messageHandler, scope)

```

**Gateway Message Handler (I also added a Session Event Message Handler with below to try it out)**  
_GatewayNextTab_

```
    messageType = 'SessionNextTab'
    scope = 'session'
    system.perspective.sendMessage(messageType, scope)

```

**Script Config on Tab Container Root**  
_Message Type = SessionNextTab_

```
self.props.activeTab = (self.props.activeTab + 1) % self.custom.total_tabs
```

---

<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 25, 2020, 4:05pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/6 "2020-06-25T16:05:58Z")

</div>

Ah, okay. Two mistakes on my part, and sort of one mistake on your part (you didn’t double-check my work, so you get some of the blame 😉 ).

I’ve updated my post because you do want SESSION Event - not GATEWAY Event (I’m sorry, I’m only halfway through my morning coffee).

In your code you removed the keyword designations, so your arguments are being interpreted incorrectly; your use of `system.perspective.sendMessage()` will interpret your arguments as the `messageHandler` arg and the `payload` arg. You need to specify the args in this manner, because you are NOT supplying a payload:

```auto
# we need to supply an empty payload arg AND we need to use the "scope" keyword
messageType = 'SessionNextTab'
scope = 'session'
system.perspective.sendMessage(messageType, payload={}, scope=scope)

```

---

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [June 25, 2020, 8:24pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/7 "2020-06-25T20:24:44Z")

</div>

Not sure why I am unable to get it to work. I feel as if the Gateway Timer isn’t reaching the messages aren’t reaching the tab container message handler.

---

<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 25, 2020, 8:26pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/8 "2020-06-25T20:26:20Z")

</div>

What I would recommend is using a line of logging as the first piece of each so that you can see where the messages are being heard. I’ll set up an actual working example and screenshot the settings.

---

<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 25, 2020, 9:42pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/9 "2020-06-25T21:42:22Z")

</div>

Okay, this works for me:

**Gateway Timer Event/Script:**  
 ![Screen Shot 2020-06-25 at 1.39.01 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/6816a15f67ef15569cd4bc239270ec298452ee48.png)

 ![Screen Shot 2020-06-25 at 1.38.52 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d564dc85e264bba73902711fd8535592e7cc2ea.png)

Session Message Event/Script:

 ![Screen Shot 2020-06-25 at 1.39.19 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b9a204f87d528dd8642b32d8e602535557f971d5.png)

Component Message Handler:

 ![Screen Shot 2020-06-25 at 1.39.38 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8f88959af6cad9781fb2b28aa3e849106b7b9663.png)

Gateway logging:

 ![Screen Shot 2020-06-25 at 1.38.16 PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/104a567cb83d62582ab8b00b90d1cfe52ca5672e.png)

My Tab Container is successfully flipping to the next tab every five seconds, and goes from the last to the first when after the last has been displayed for five seconds.

---

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [June 26, 2020, 12:40pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/10 "2020-06-26T12:40:20Z")

</div>

I'm getting the confirmations in the Gateway Logger!  
I'm also getting an error:

> Error running TabTest@C/root/TabContainer.onMessageReceived(self, payload): Traceback (most recent call last): File "function:onMessageReceived", line 3, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'tab\_count'

Tried the total\_tabs mentioned earlier as well.

> Error running TabTest@C/root/TabContainer.onMessageReceived(self, payload): Traceback (most recent call last): File "function:onMessageReceived", line 3, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'total\_tabs'

---

<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 26, 2020, 4:28pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/11 "2020-06-26T16:28:50Z")

</div>

You need to set your own custom property on the Tab Container.  
 ![Screen Shot 2020-06-26 at 9.27.16 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/98f78f5e3c3a1ee48659289c1365c4250828ff7a.png)

---

<div class="post-metadata">

**Author:** ![Saul\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Saul\_Garcia](https://forum.inductiveautomation.com/u/Saul_Garcia)\
**Post date:** [August 5, 2024, 5:42pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/12 "2024-08-05T17:42:34Z")

</div>

Hi, i'm new to ignition Perspective so i am currently working on a similar project that involves a main view configured as a tab container, in this view i added in total 4 tabs (0,1,2,3) and in each tab i added a coordinate container for working in it, i am having trouble with the scripting in general, i know how to add all the scripting except the gateway logging, but apart from that, it is not working, so i dont know what to do with the tab timer project.  
hoping for the support, looking forward for the help.

---

<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:** [August 5, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/13 "2024-08-05T17:56:10Z")

</div>

Welcome to the forum.  
It's going to be hard to debug your problem with the information given. Please confirm with screengrabs that you have done all the steps in cmallonee's post #9.

---

<div class="post-metadata">

**Author:** ![Saul\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Saul\_Garcia](https://forum.inductiveautomation.com/u/Saul_Garcia)\
**Post date:** [August 5, 2024, 7:22pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/14 "2024-08-05T19:22:41Z")

</div>

sure!  
the main information described is this:  
First pic is the perspective menu  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b98a3908d323b706c7027f623ec9865dffb49e8.png)  
Second pic is the arrange of the proyect, with the main view as a tab container and in each tab there is a coordinate container  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d0b0225a2dd170ffde4a14b64fa14197df7ba59b.png)

---

<div class="post-metadata">

**Author:** ![Saul\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Saul\_Garcia](https://forum.inductiveautomation.com/u/Saul_Garcia)\
**Post date:** [August 5, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/15 "2024-08-05T19:23:20Z")

</div>

continuation:  
Gateway timer script third pic

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0ec5772c4a243461a7747a6bcab898352a3f3eab.png)  
Session message handlers  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36631f24d1a31a9ae4dc4fb0a7d70fdd94bdec3e.png)  
another part  
Script configuration TabContainer  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6279998cc6cd0cac81a9cd8f9bc2ff96370f6dd.png)  
Also i added in custom properties the "tab\_count" property

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [August 5, 2024, 11:21pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/16 "2024-08-05T23:21:41Z")

</div>

Hi @Saul_Garcia, I want to make you aware of the [Carousel](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-embedding-palette/perspective-carousel) component (which wasn't out when OP posted) that can essentially automatically play through preconfigured panes on a schedule. Check it out to see if it meets your needs - its much easier to set up as you can do most of this configuration right from the Property editor in the designer.

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

---

<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:** [August 5, 2024, 11:35pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/17 "2024-08-05T23:35:58Z")

</div>

![Tabbed container listener](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0d0ea170d01d69ac14a9c4a3dbb92be10c8ee37e.png)

It looks as though you haven't saved it yet.

---

<div class="post-metadata">

**Author:** ![Saul\_Garcia](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Saul\_Garcia](https://forum.inductiveautomation.com/u/Saul_Garcia)\
**Post date:** [August 6, 2024, 3:09pm UTC](https://forum.inductiveautomation.com/t/automatically-change-tab-after-seconds-in-a-loop-perspective/36027/18 "2024-08-06T15:09:27Z")

</div>

i took the screenshot as i was typing it, so thats why it looks like it, but here it is

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd5ded74e268a8f800c144d7b33dfacb9c255a63.png)  
im still struggling with it, cause i dont know if i have to add another custom property or function that is related with the currentTabIndex  
thank you all for the support
