# Expecting one event getting same event triggered multiple times

**URL:** <https://forum.inductiveautomation.com/t/expecting-one-event-getting-same-event-triggered-multiple-times/90241>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [May 10, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/expecting-one-event-getting-same-event-triggered-multiple-times/90241 "2024-05-10T16:46:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devty](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@devty](https://forum.inductiveautomation.com/u/devty)\
**Post date:** [May 10, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/expecting-one-event-getting-same-event-triggered-multiple-times/90241/1 "2024-05-10T16:46:30Z")

</div>

I am trying to debug a situation where I send a message to the root component of a view to persist it's state to the database. When I click the save button on the view which sends that perspective message i am getting 4 records created. effectively it is triggered multiple times from one click.

Any ideas on how to troubleshoot the same event getting triggered multiple times?

---

<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:** [May 10, 2024, 5:49pm UTC](https://forum.inductiveautomation.com/t/expecting-one-event-getting-same-event-triggered-multiple-times/90241/2 "2024-05-10T17:49:53Z")

</div>

It sounds as though you have the same message handler in multiple places or you the change to the root component is retriggering the sendMessage. Add a logger to the message handler script and record which handler caught the message.

Without more information there is little else we can offer.

---

<div class="post-metadata">

**Author:** ![devty](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@devty](https://forum.inductiveautomation.com/u/devty)\
**Post date:** [May 14, 2024, 3:47pm UTC](https://forum.inductiveautomation.com/t/expecting-one-event-getting-same-event-triggered-multiple-times/90241/3 "2024-05-14T15:47:04Z")

</div>

I am building a comment system and the form for user entry was updating view state.

the idea was to have a central source of truth for state and then when the comment is ready they insert / update to database.

database inserts were doing 4 with each mouse click on the button.

I ended up scrapping the idea of message handler and just built logic to update the view.custom.form\_state object and now I get one db insert.

sorry for not articulating my original question better. I am operating from alot of ignorance here.
