# Perspective: How to delay script run to close dock in x seconds

**URL:** <https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741>\
**Category:** Ignition Early Access\
**Created:** [July 22, 2019, 3:54am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741 "2019-07-22T03:54:04Z")\
**Posts on this page:** 15\
**Page:** 1

<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:** [July 22, 2019, 3:54am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/1 "2019-07-22T03:54:04Z")

</div>

I have a footer that I want to display for a couple seconds and then hide again, but I note that invokeLater isn’t available for Perspective, and the Timer component doesn’t exist either. I’m not sure how else to do this?

Cheers!

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 22, 2019, 4:57am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/2 "2019-07-22T04:57:41Z")

</div>

Make a custom property **MyKey** on the footer.  
Bind the visible property of the footer to

`dateIsBefore(now(1000),{this.custom.MyKey})`

Now you can set the value of MyKey to now + 5 seconds.  
`self.getSibling("Label").custom.MyKey = system.date.addSeconds(system.date.now(),5)`

---

<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:** [July 22, 2019, 5:10am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/3 "2019-07-22T05:10:41Z")

</div>

Interesting idea, but setting the visible property just hides the contents of the View and doesn’t hide the View itself. I need to call the function `system.perspective.closeDock('Footer')`.

If I could use your method with a propertyChange event handler though it would work, I just can’t find any such event handler…

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 22, 2019, 5:13am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/4 "2019-07-22T05:13:53Z")

</div>

Would it do what you’re looking for if instead of binding the visible property, you put that binding on a custom property, and then right-click on the custom property, select Add Change Script… and write your script there?

---

<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:** [July 22, 2019, 5:17am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/5 "2019-07-22T05:17:29Z")

</div>

Perfect! I forgot those were there, cheers. Works like a charm now thanks to both of you.

---

<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:** [July 22, 2019, 5:47am UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/6 "2019-07-22T05:47:29Z")

</div>

Hmm, I might have jumped the gun. My onStartup event (tried on the View as well as the root objects) doesn’t seem to be firing after it opens for the first time. It seems like the dock doesn’t actually get closed, but more it’s hidden in the background. So when I open it again, it doesn’t actually fire any of the startup events. I could pass in a parameter to the View which I could then use to force it to run the script… but it’s all feeling overly complicated for such a seemingly simple task, that I’m sure there must be a more efficient way?

---

<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 22, 2019, 4:57pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/8 "2019-07-22T16:57:26Z")

</div>

You want to be careful using parameters with Docked Views, as Parameters are really meant to be used for initial construction (it just happens that in most instances a parent View has direct access to parameter values, and so in those instances they can be updated on-the-fly - Docked Views do not have that capability).

My recommendation is (surprise, surprise) to use Perspective’s `sendMessage()` function. Your Docked View would need to have a listener present (you can use the root)

In the Docked View listener (listening at session scope):

```auto
dockedViewId = value['dockedViewId']
pageId = value['pageId']
sessionId = value['sessionId']
if value['command'] == 'open':
    system.perspective.openDock(id=dockedViewId, pageId=pageId], sessionId=sessionId)
elif value['command'] == 'close':
    system.perspective.closeDock(id=dockedViewId, pageId=pageId], sessionId=sessionId)

```

You can trigger the open/close wherever you like, but it should call out to a project script:

```auto
project.myScript.manageDockedView(dockedViewId='myDockedViewId', pageId=page.props.pageId, sessionId=session.props.id, command='open')

```

Project Script:

```auto
def manageDockedView(command, dockedViewId, pageId, sessionId):
    system.perspective.sendMessage(messageType='MANAGEDOCKEDVIEW', payload={'command':command, 'dockId':dockedViewId, 'pageId':pageId, 'sessionId':sessionId}, scope='session')

```

---

<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:** [July 22, 2019, 5:14pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/9 "2019-07-22T17:14:11Z")

</div>

Ok, I think I got it. In order to delay it, I would still use the now+3s part, but the message handler on the docked view would effectively trigger the dock to update the ‘close time’. I’ll give it a go when I’m back in the office, cheers!

---

<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 22, 2019, 5:15pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/10 "2019-07-22T17:15:53Z")

</div>

Ah, I forgot this entire thread was about delaying the action!

What I would do is include the delay as part of the project script as an optional argument and just sleep that long before executing the rest of the script.

---

<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:** [July 22, 2019, 5:20pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/11 "2019-07-22T17:20:45Z")

</div>

Ok, so literally just (excluding delay param for simplicity here):

```auto
import time
time.sleep(3)

```

I thought this might lock up the UI like it does in vision, but no?

---

<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:** [July 22, 2019, 5:25pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/12 "2019-07-22T17:25:21Z")

</div>

No UI to lockup via scripting - all your scripts are running in a (dedicated, per-session) channel on the Gateway. The UI never actually runs your code - it’s all running via JS.

---

<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:** [July 22, 2019, 5:27pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/13 "2019-07-22T17:27:21Z")

</div>

Awesome, I’ll give it a go. Thanks guys

Edit: Just tested, and now working as intended, cheers. Perspective is still extremely new to me… 😶

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [August 8, 2025, 9:41pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/14 "2025-08-08T21:41:48Z")

</div>

Sorry to open an old thread, but this I have a question on some of the statements above. I’m trying to get rid of some of my sleeps, so I have implemented this solution in a couple of areas. But let’s say I want a Perspective button to pulse a boolean tag for one second. If I can call a project script, and it executes in a different thread, then I can just do that without using any other redirection through message handlers?

I could make a script in the project scripts like

```python
def synchronousOneSecondTagPulse(tagPath, delay = 1000):
        
    system.tag.writeBlocking([tagPath], [1])    
    import time
    time.sleep(delay / 1000)
    system.tag.writeBlocking([tagPath], [0])
    return

```

And call it from the Perspective button event and it would be ok? I would think not, but wanted to check because it seemed based on the above that this would be OK.

Thanks

---

<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:** [August 8, 2025, 9:56pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/15 "2025-08-08T21:56:01Z")

</div>

Merely calling out to the project library is exactly equivalent to just writing your code inline from a threading aspect.

That is, there is **no difference** between these two scenarios:

```python
# Some Action Performed Script
def onActionPerformed():
    doSomething()
    doSomethingElse()

```

* * *

```python
# Some Action Performed Script
def onActionPerformed():
    projectLibraryFunction()

# Some Project Library
def projectLibraryFunction():
    doSomething()
    doSomethingElse()

```

You can mentally conceive of calling out a project library as the computer copying and pasting whatever's in the project library script directly into whatever script you're writing. All it affects is **packaging** , not **execution**.

If you want something to happen on an indirect thread, you have to do that manually.

In line with that advice:

1. Momentarily pulsing things is a fragile operation from any SCADA; see myriad threads on this forum about the hazards of momentary buttons. In general, you _must_ design things as if any "off" signal from SCADA following an "on" signal is not guaranteed to ever be delivered.
2. Time delays are guaranteed to be less precise than you'd like them to be, and even with _careful_ garbage collection tuning prepare for a "one second" delay to range anywhere from less than a second to multiple seconds.
3. Basically any kind of timed/blocking wait is an antipattern in Ignition. Design things to be 'event driven' and react to events as needed, or rely on platform facilities like timer scripts instead of creating your own busy loops.
4. You should not block Perspective worker threads (where your actions will implicitly be running when invoked from Perspective GUI interaction) any longer than necessary.

---

<div class="post-metadata">

**Author:** ![ken.maze](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ken.maze/32/85876_2.png) [@ken.maze](https://forum.inductiveautomation.com/u/ken.maze)\
**Post date:** [August 11, 2025, 1:34pm UTC](https://forum.inductiveautomation.com/t/perspective-how-to-delay-script-run-to-close-dock-in-x-seconds/26741/16 "2025-08-11T13:34:01Z")

</div>

Got it, that’s what I thought. Thanks for the extra clarification.
