# The 'onStartup' event script fires multiple times when the project is saved

**URL:** <https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 30, 2025, 12:05pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608 "2025-01-30T12:05:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [January 30, 2025, 12:05pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/1 "2025-01-30T12:05:44Z")

</div>

Hello everyone,

I have a script running in the `onStartup` event for all the views in a project to save log data.

The issue is that every time I save a view, and a client is currently on that view, the script fires again, causing fake logs to be saved in the database.

How can I prevent this?

Thank you for your help!

---

<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 30, 2025, 1:01pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/2 "2025-01-30T13:01:53Z")

</div>

You cannot. The startup event is almost never the right event to use for such purposes. Please share what you actually need done.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [January 30, 2025, 1:22pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/3 "2025-01-30T13:22:28Z")

</div>

I understand. I just need to log all the pages that users navigate to.

The script in the `onStartup` is is as follows:

```python

	# Logger 
	viewName = self.view.id.split('@')[0]
	user = self.session.props.auth.user.userName
	project = system.util.getProjectName()
	timezone = self.session.props.device.timezone.id 
	Generali.Session_Info.userSessionInfo(user=user, project=project, viewName=viewName, timezone=timezone)

```

The function that is called just insert in the database the data according to my needs.

---

<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 30, 2025, 1:56pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/4 "2025-01-30T13:56:58Z")

</div>

But that isn't going to catch all of the navigation. That event doesn't catch all returns to a view, so is not fit for your stated purpose. You should be instrumenting the actions where navigation is **initiated**.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Furlani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benjamin_furlani/32/66084_2.png) [@Benjamin\_Furlani](https://forum.inductiveautomation.com/u/Benjamin_Furlani)\
**Post date:** [January 30, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/5 "2025-01-30T15:19:55Z")

</div>

> [@Aiasa21](#):
>
> The function that is called just insert in the database the data according to my needs.

Move this to a project script that will take parameters and then when you click on a navigation button or have an action like @pturmel said to navigate run it there. It will be a simple one-liner `someScript.logNavigation` or something of the sort.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [January 31, 2025, 10:26am UTC](https://forum.inductiveautomation.com/t/the-onstartup-event-script-fires-multiple-times-when-the-project-is-saved/101608/6 "2025-01-31T10:26:24Z")

</div>

So for example in my case I should work on the `menuTree` component where I manage the navigation?

@Benjamin_Furlani I'll make a test, thank you for the help
