# Any way to toggle visibility of a Shared Docked View?

**URL:** <https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [March 19, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704 "2021-03-19T21:09:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 19, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/1 "2021-03-19T21:09:27Z")

</div>

Is there any way to toggle a shared docked view at the start-up of a perspective session?

I want to hide or show a banner based off of a tag value–and it needs to be across the whole session once it starts up. (I tried system.perspective.closeDock() within a session startup script but that didn’t work because a page wasn’t attached to the thread.) But I don’t have a specific page b/c it’s a shared view–it’s on all pages.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 20, 2021, 12:16am UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/2 "2021-03-20T00:16:33Z")

</div>

You’ll most likely need to use message handling. On the dock, have a message handler that opens/closes itself based on the message it receives. Make sure you get the right scope.

---

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 22, 2021, 12:38pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/3 "2021-03-22T12:38:49Z")

</div>

I don’t see a way for docks to handle messages.  
I know I could handle a message in each view I make, but I would like to be able to set it in one place since it is a shared dock on all pages.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 22, 2021, 1:08pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/4 "2021-03-22T13:08:01Z")

</div>

A shared dock is always “open” in memory, you just hide and show it when you need to.

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

Then just use sendMessage to open or hide it:

```auto
system.perspective.sendMessage('toggle-test-dock', False, 'session') # hide it
system.perspective.sendMessage('toggle-test-dock', True, 'session') # show it

```

---

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 22, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/5 "2021-03-22T13:11:06Z")

</div>

Right, but this approach requires that I add this script to every single view I make, correct?

I’m looking for a global way to handle this, where I only make a change in one spot. That way I don’t have to manage duplicate code and remember to add that code to ever new view we create.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 22, 2021, 1:14pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/6 "2021-03-22T13:14:57Z")

</div>

Well, you need to add the message handler to every single **shared dock** you create that you want to be able to show or hide from a tag, but I daresay you’ll only have a few of these. You should be able to call those single-line sendMessage functions from anywhere, page or tag/session prop. So unless that’s duplicating code (reusing library functions), it should get you what you need, no?

Note: if using within a tag, you’ll need to use the gateway version:  
[https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage](https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage)

---

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 22, 2021, 1:47pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/7 "2021-03-22T13:47:17Z")

</div>

Right but where do I call the “sendMessage” function?  
Calling it at session startup does not work. (perhaps because the dock hasn’t yet loaded on start up so it misses the message).

I can send the message and successfully hide the view when a page gets started up, but then I have to send the message on the start up of every page. Which goes back to having to manage startup scripts for every view created.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2021, 1:48pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/8 "2021-03-22T13:48:58Z")

</div>

Have your dock send **itself** the message, too, on its startup.

---

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 22, 2021, 2:02pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/9 "2021-03-22T14:02:30Z")

</div>

That was an intriguing suggestion. I tried it out and unfortunately once I navigate to a new page the docked view comes right back up. (I guess shared views only start up once, not after every page load.)

So I’d still need to send the message on the startup of every page.

---

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [March 22, 2021, 6:31pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/10 "2021-03-22T18:31:45Z")

</div>

There isn’t some sort of “message” banner or other component that I’m not aware of, is there?

That’s kind of ideal for what I want. (e.g. when a website is being updated or a server is down, a banner will appear at the top of the webpage.)

---

<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:** [March 22, 2021, 6:40pm UTC](https://forum.inductiveautomation.com/t/any-way-to-toggle-visibility-of-a-shared-docked-view/44704/11 "2021-03-22T18:40:06Z")

</div>

> [@sydney.bergeron](#):
>
> There isn’t some sort of “message” banner or other component that I’m not aware of, is there?

No, but that's an interesting [idea](https://ideas.inductiveautomation.com/ignition-features-and-ideas)...
