# Update nodes dynamically based on connection

**URL:** <https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176>\
**Category:** General\
**Created:** [19 October 2023 04:48 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176 "2023-10-19T04:48:27Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![chiru](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@chiru](https://discourse.nodered.org/u/chiru)\
**Post date:** [30 October 2023 12:21 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176/21 "2023-10-30T12:21:16Z")

</div>

sure.. 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:** [30 October 2023 12:21 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176/22 "2023-10-30T12:21:24Z")

</div>

> [@chiru](#):
>
> how to design the nodes such that it can act as LHS or RHS dynamically.

Conventionally, one would use msg.topic to identify which is which.

---

<div class="post-metadata">

**Author:** ![chiru](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@chiru](https://discourse.nodered.org/u/chiru)\
**Post date:** [30 October 2023 12:24 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176/23 "2023-10-30T12:24:21Z")

</div>

@Colin, thanks for the suggestion.  
Based on connection, I want to identify if an operand node acts as LHS or RHS node to subtraction node. An operand node can act as LHS to one subtraction node and RHS for other subtraction node and so on.  
I was not able to achieve this with msg.topic.. Hope I haven't missed anything.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 October 2023 12:32 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176/24 "2023-10-30T12:32:29Z")

</div>

> [@chiru](#):
>
> I was not able to achieve this with msg.topic.. Hope I haven't missed anything.

Potentially....  
Don't re-evaluate the same `msg`, Example :

`msg` is an object - therefore is `pass-by-ref`

```auto
/ * Bad */
msg.topic = 1
self.send(msg)
msg.topic = 2
self.send(msg)

```

keep it to 2 outputs, and derive a message using properties from `msg`

```auto
let A = {
   ...msg,
}
A.topic = 1

let B = {
  ...msg,
}
B.topic = 2

self.send([A,B])

```

I think doing `...msg` should yield 2 different objects (but I could be wrong)

---

<div class="post-metadata">

**Author:** ![chiru](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@chiru](https://discourse.nodered.org/u/chiru)\
**Post date:** [30 October 2023 12:35 UTC](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176/25 "2023-10-30T12:35:12Z")

</div>

@marcus-j-davies  
Got it. Thanks.

[Previous page](https://discourse.nodered.org/t/update-nodes-dynamically-based-on-connection/82176.md?page=1)
