# Forced initialisation

**URL:** <https://discourse.nodered.org/t/forced-initialisation/38314>\
**Category:** General\
**Created:** [31 December 2020 11:22 UTC](https://discourse.nodered.org/t/forced-initialisation/38314 "2020-12-31T11:22:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surefire01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/surefire01/32/71490_2.png) [@Surefire01](https://discourse.nodered.org/u/Surefire01)\
**Post date:** [31 December 2020 11:22 UTC](https://discourse.nodered.org/t/forced-initialisation/38314/1 "2020-12-31T11:22:18Z")

</div>

Chaps  
Was wondering how to automatically force an initialisation of a flow after deployment. My flow won't function correctly until I enter information by moving a slider in the dashboard which then sends data to a function node which then uses this data to produce an output.

Thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 December 2020 12:06 UTC](https://discourse.nodered.org/t/forced-initialisation/38314/2 "2020-12-31T12:06:31Z")

</div>

You can use an Inject node set to fire on startup to inject an appropriate initial value into the flow.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [31 December 2020 12:39 UTC](https://discourse.nodered.org/t/forced-initialisation/38314/3 "2020-12-31T12:39:55Z")

</div>

As Colin says, this indicates that you are not initialising your value. You should, in general, never make an assumption about the front-end (Dashboard in your case). You should always initialise all values to something sensible and/or to whatever value was last provided. That last part might need you to save the data to a flow/global variable that you read on startup or alternatively, you could use an MQTT topic with the retained flag and a suitable subscription.

---

<div class="post-metadata">

**Author:** ![Surefire01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/surefire01/32/71490_2.png) [@Surefire01](https://discourse.nodered.org/u/Surefire01)\
**Post date:** [4 January 2021 08:34 UTC](https://discourse.nodered.org/t/forced-initialisation/38314/4 "2021-01-04T08:34:43Z")

</div>

Thanks for the advice chaps. Will look into the suggested options.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 March 2021 08:34 UTC](https://discourse.nodered.org/t/forced-initialisation/38314/5 "2021-03-05T08:34:51Z")

</div>

Closed on 5 March 2021 08:34 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
