# Triggering an onClick with scripting

**URL:** <https://forum.inductiveautomation.com/t/triggering-an-onclick-with-scripting/26412>\
**Category:** Ignition Early Access\
**Created:** [July 9, 2019, 11:07pm UTC](https://forum.inductiveautomation.com/t/triggering-an-onclick-with-scripting/26412 "2019-07-09T23:07:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfryar](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jfryar](https://forum.inductiveautomation.com/u/jfryar)\
**Post date:** [July 9, 2019, 11:07pm UTC](https://forum.inductiveautomation.com/t/triggering-an-onclick-with-scripting/26412/1 "2019-07-09T23:07:22Z")

</div>

I have a script attached to a button in perspective that I would like to trigger when the view is opened. I know I can use the onStartup event on the view but I would rather not have two copies of the script floating around. I also don’t use this script repeatedly so it isn’t a good candidate for a global script resource. Is there a way to trigger the onClick event in this button using scripting within the onStartup event on the view?

---

<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 9, 2019, 11:22pm UTC](https://forum.inductiveautomation.com/t/triggering-an-onclick-with-scripting/26412/2 "2019-07-09T23:22:49Z")

</div>

Don’t try to fire a click event programatically.  
Move the logic into a [message handler](https://docs.inductiveautomation.com/display/DOC80/Component+Message+Handlers) with the appropriate scope.  
View `onStartup` _and_ the button’s `onClick` can both just fire the message hook.
