# Refresh action event doesn't trigger onStartup event

**URL:** <https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148>\
**Category:** Ignition Early Access\
**Created:** [March 7, 2019, 11:20pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148 "2019-03-07T23:20:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nburt](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nburt](https://forum.inductiveautomation.com/u/nburt)\
**Post date:** [March 7, 2019, 11:20pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/1 "2019-03-07T23:20:29Z")

</div>

I’m wondering if there is a way to re-trigger the onStartup event on a component/view.  
I have a Refresh action on my onClick event and the page is definitely refreshed but it is displayed exactly as its previous state without the onStartup event being triggered. Refreshing the web browser (CTRL R or F5) gives the same result.

Is this an expected outcome?  
If so, is there a way to re-trigger the onStartup event? I suppose I could have a custom script that navigates me away from the view and then back to the view but that seems hacky.

---

<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:** [March 7, 2019, 11:21pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/2 "2019-03-07T23:21:34Z")

</div>

Could you move whatever logic you need to fire again into a message handler, then just dispatch a message from wherever you need to re-fire it?

---

<div class="post-metadata">

**Author:** ![nburt](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nburt](https://forum.inductiveautomation.com/u/nburt)\
**Post date:** [March 7, 2019, 11:27pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/3 "2019-03-07T23:27:18Z")

</div>

That should definitely accomplish what I need for now, but eventually I would also like that logic to be triggered when the user refreshes the web browser itself.

And just so I can plan ahead I want to make sure I know what the intent of the Refresh action is.

---

<div class="post-metadata">

**Author:** ![victor1](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@victor1](https://forum.inductiveautomation.com/u/victor1)\
**Post date:** [June 4, 2020, 1:59pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/4 "2020-06-04T13:59:58Z")

</div>

There is a way to run a script whenever the view starts and when the page is refreshed

---

<div class="post-metadata">

**Author:** ![tony.petruzzi1](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tony.petruzzi1](https://forum.inductiveautomation.com/u/tony.petruzzi1)\
**Post date:** [May 4, 2021, 3:43pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/5 "2021-05-04T15:43:53Z")

</div>

I’m facing this issue as well, what is the status of this? Has it been filed as a bug? You would think that issuing a refresh and redrawing the page would fire the event.

---

<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:** [May 4, 2021, 3:49pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/6 "2021-05-04T15:49:54Z")

</div>

For a variety of reasons, we have to make Perspective ‘defensive’ about certain things with the move to a browser-hosted environment.  
For instance - from the backend, there’s _no way_ to distinguish between the user refreshing the tab, and the user momentarily losing connection and then getting it back (common on WiFi & cellular networks, especially for mobile devices).  
So it’s somewhat of an impossible problem to solve. We _could_ expose some event every time the ‘frontend’ of the page rebuilt - but it’s not really the same as `onStartup`, because the startup event is actually triggered by the _backend_ logic (running on the gateway) - where we have a lot more control over things and a lot more stability. If you’d find such an event useful, despite the potential drawbacks, you’re welcome to file an [ideas post](http://ideas.inductiveautomation.com) - but it’s not exactly a bug with the current implementation (and changing it at this point would just cause more problems).

---

<div class="post-metadata">

**Author:** ![tony.petruzzi1](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tony.petruzzi1](https://forum.inductiveautomation.com/u/tony.petruzzi1)\
**Post date:** [May 4, 2021, 3:57pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/7 "2021-05-04T15:57:12Z")

</div>

I get it… but what is the official workaround then? This behavior causes all sorts of issues especially for business logic that depends on things happening when the page is redrawn. I don’t see why you couldn’t just issue an ajax or websocket request when the page is reload to the backend to refire those events. You are using react as your framework so communication with your backend shouldn’t be an issue.

---

<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:** [May 4, 2021, 3:58pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/8 "2021-05-04T15:58:41Z")

</div>

Right - it’s not that we _can’t_, it’s that we _didn’t_ when Perspective was first created, and changing it now would be a breaking change (suddenly, business logic relying on startup firing N times per session is going to start firing N\*X times per session). We would have to introduce an `onRefresh` or some other event type, _new_.

---

<div class="post-metadata">

**Author:** ![tony.petruzzi1](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tony.petruzzi1](https://forum.inductiveautomation.com/u/tony.petruzzi1)\
**Post date:** [May 6, 2021, 12:40pm UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/9 "2021-05-06T12:40:02Z")

</div>

That would be very much appreciated. I already put in a feature request.

---

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [July 26, 2022, 9:46am UTC](https://forum.inductiveautomation.com/t/refresh-action-event-doesnt-trigger-onstartup-event/23148/10 "2022-07-26T09:46:51Z")

</div>

I suppose that in this case a gatewayEvent can accomplish the task, they now have only an gatewayEvent-Update.  
I think hat a session-refresh can be a sort of update where a system variable, that is built at startup, change its state when the refresh of the session is done. So an update where all is the same  
can be a trigger for a session refresh.  
Is my hypothesis realistic?

Thx. C.
