# Working with multiple inputs on uibuilder node

**URL:** <https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701>\
**Category:** General\
**Created:** [23 October 2020 05:19 UTC](https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701 "2020-10-23T05:19:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pektin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pektin/32/23401_2.png) [@Pektin](https://discourse.nodered.org/u/Pektin)\
**Post date:** [23 October 2020 05:19 UTC](https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701/1 "2020-10-23T05:19:28Z")

</div>

Hi, im relatively new to the uibuilder node and VueJS. I have following problem:

For example, if i have multiple inputs to a uibuilder node over msg.payload. I catch them with the uibuilder.onChange() function. So good so far. Now i've got one input from a node, lets say testVal (msg.payload.testVal) and an input from another node - testVal2 (msg.payload.testVal2).

**uibuilder.onChange('msg') inside index.js**

```auto
 vueApp.testVal = msg.payload.testVal;
 vueApp.testVal2 = msg.payload.testVal2;

```

Now i'll see testVal updating every second due to the back-end but when testVal2 triggers uibuilder.onChange() cause its updated too, testVal will have no value in that moment causing it to display wrong/nothing. Im using the link nodes to connect the dashboard to the individual components on each flow. Is there a way to seperate the values so they don't disturb each other?

---

<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:** [23 October 2020 19:52 UTC](https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701/2 "2020-10-23T19:52:54Z")

</div>

Hi. I generally make use of msg.topic to help differentiate different incoming data since that is usually easy to set in Node-RED and it doesn't affect the payload.

Either way, what you need in your onChange function is an `if` or a `switch` statement to differentiate between the different msg types (which is why it is easier to use `msg.topic`).

```auto
if ( msg.payload.testVal ) {
    // ... do stuff on this msg
} else {
   // ...
}

```

Or better:

```auto
if ( msg.topic === 'type1' ) {
    // ... do stuff on testVal
} else {
   // ... do stuff with testVal2
}

```

It is tempting to do the logic inside the if/switch. But you will generally thank yourself if you create a separate function to encapsulate the logic. But that is a matter of style.

---

<div class="post-metadata">

**Author:** ![Pektin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pektin/32/23401_2.png) [@Pektin](https://discourse.nodered.org/u/Pektin)\
**Post date:** [25 October 2020 02:53 UTC](https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701/3 "2020-10-25T02:53:49Z")

</div>

Thank you very much! I think i'll do it in a seperate function 🙂

---

<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:** [8 November 2020 02:53 UTC](https://discourse.nodered.org/t/working-with-multiple-inputs-on-uibuilder-node/34701/4 "2020-11-08T02:53:59Z")

</div>

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