# Invoking event scripts from message handler scripts?

**URL:** <https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [January 5, 2022, 5:43pm UTC](https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696 "2022-01-05T17:43:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user69](https://avatars.discourse-cdn.com/v4/letter/u/58f4c7/32.png) [@user69](https://forum.inductiveautomation.com/u/user69)\
**Post date:** [January 5, 2022, 5:43pm UTC](https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696/1 "2022-01-05T17:43:29Z")

</div>

I have a perspective page with a button component whose an “on action performed” event script performs various updates to a backend.

The page also has the ​message handler script that populates some dropdown components with data from barcodes. Is it possible for this message handler script to execute the “update” button’s “on action performed” event script?

---

<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:** [January 5, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696/2 "2022-01-05T17:52:04Z")

</div>

No, but you shouldn’t have complex scripts in events anyways. Move the code to a project script module function. Then either origin can call the same logic.

---

<div class="post-metadata">

**Author:** ![user69](https://avatars.discourse-cdn.com/v4/letter/u/58f4c7/32.png) [@user69](https://forum.inductiveautomation.com/u/user69)\
**Post date:** [January 5, 2022, 7:07pm UTC](https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696/3 "2022-01-05T19:07:31Z")

</div>

Another possibility brought to my attention is to create a custom method, call it `execute`, that performs the logic of the button’s current event script. The event script can then use `self.execute()`, and the page’s message handler script can call `self.getChild("myUpdateButton").execute()` as necessary.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 5, 2022, 10:01pm UTC](https://forum.inductiveautomation.com/t/invoking-event-scripts-from-message-handler-scripts/54696/4 "2022-01-05T22:01:07Z")

</div>

> [@user69](#):
>
> `self.getChild("myUpdateButton").execute()` as necessary.

And if you want to call that same code from another view when this one isn't open? If you take @pturmel's suggestion and move the code to a project script that is independent of view, you can call that code from anywhere in the project and not worry about duplicating the code or the component not being available.

Project script is the way to go, IMNSHO
