# Dynamically creating widgets with payload in same msg - payload is not always reflected

**URL:** https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966
**Category:** Dashboard
**Created:** [4 July 2025 19:51 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966 "2025-07-04T19:51:42Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![SandeepA](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandeepa/32/63225_2.png) [@SandeepA](https://discourse.nodered.org/u/SandeepA)
#### Post date: [4 July 2025 19:51 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/1 "2025-07-04T19:51:43Z")

</div>

Hi - I face a strange issue . And this is seen on multiple widgets - forms / dropdown etc.

1. I configure multiple widgets (forms etc) using dynamically msg.ui\_update
2. In the same message i also add the payload to msg.payload.

Expectation : Widget would be configured and the payload would be shown.  
Actual : While the widget gets dynamically defined - sometimes the payload sent is not reflected. The widgets continues to show earlier payload (probably its stored internally) or nothing.  
(The behavior is inconsistent and not always reproducible - but very often seen)

To overcome this - i need to send the same msg to widget a second time with the delay. So i have a flow with bunch of such widgets and delay nodes to handle the above issues.

See the snapshot of a simplistic flow. My flows have 30-40 widgets.

This leads to Maintainance issues, unnecessary nodes leading to heavier flows.  
Plus due to the delay sometimes the user experience gets impacted as he sees payload on screen and with delay it changes to new payload.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92be70484024ddbfab651ae8686ee64b9e1d33ea.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 July 2025 21:20 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/2 "2025-07-04T21:20:30Z")

</div>

> [@SandeepA](#):
>
> To overcome this - i need to send the same msg to widget a second time with the delay. So i have a flow with bunch of such widgets and delay nodes to handle the above issues.

this might suggest that the downstream functions are modifying the message before it reaches the target. By adding a trigger to resent it, you have created a scenario where two wires leave a node and due to underlying rules in the core, any msg that leaves a node and has to travel more than 1 parallel wire, every messages gets cloned (details are hazy, the first might not, but all others do). The side effect is that the cloned message cannot be referentially modified by downstream/upstream changes.

Try this:

1. delete the delay nodes
2. clone the `msg` at the start of each function and return the clone

```auto
const m = RED.util.cloneMessage(msg)
...
m.whatever = "new value"
...
return m

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 July 2025 22:40 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/3 "2025-07-04T22:40:14Z")

</div>

On second thoughts, this might be a timing thing. It might be a dashboard issue. It may even the way it has to be - in which case we will document it.

Would you prepare a reproducible flow with and without the extra delay please?

---

<div class="post-metadata">

### Author: ![SandeepA](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandeepa/32/63225_2.png) [@SandeepA](https://discourse.nodered.org/u/SandeepA)
#### Post date: [5 July 2025 06:38 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/4 "2025-07-05T06:38:57Z")

</div>

Thanks @Steve-Mcl .

> [@Steve-Mcl](#):
>
> this might suggest that the downstream functions are modifying the message before it reaches the target.

Not fully clear what you suggest. I do this only for db2 widgets as target. Plus all my db2 widgets are "non passthrough". So unless user clicks the widget - msg cannot go to next node. I would assume that when the widget gets 2 msgs with same client - the last one prevails.

> [@Steve-Mcl](#):
>
> clone the `msg` at the start of each function and return the clone

Thanks. But delay may be needed. My observation is unless i add some delay - race condition occurs and its not guaranteed that that the ui\_update reaches before payload. My intent here is to not have these delay nodes or even cloned messages (it still means multiple messages passing through the system ) and be able to pass both msg.ui\_update and msg.payload in same message. This is obviously, unless we document (even post this) - that for dynamically configured widgets - msg.ui\_update and msg.payload should be on different successive messages.

> [@Steve-Mcl](#):
>
> On second thoughts, this might be a timing thing.

This is my guess as well. Or how the node ingests a message. My view if the msg has both ui\_update and payload - ui\_update processing should be done and only once done payload attached to the widget .

> [@Steve-Mcl](#):
>
> Would you prepare a reproducible flow with and without the extra delay please?

I will try. I dont see this behavior always. But have seen it very often to eventually realize this issue and add delay nodes to my entire flow. So having a reproducible flow may become tricky. But will give it a shot. Will come back.

---

<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: [5 July 2025 07:47 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/5 "2025-07-05T07:47:04Z")

</div>

Is not the fundamental problem that you are seeing the fact that sometimes when a message includes both payload and ui\_update that the payload is not acted upon?

Edit: If so then can you post a simple example that shows the problem?

---

<div class="post-metadata">

### Author: ![SandeepA](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandeepa/32/63225_2.png) [@SandeepA](https://discourse.nodered.org/u/SandeepA)
#### Post date: [5 July 2025 14:18 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/6 "2025-07-05T14:18:39Z")

</div>

The key word is "sometimes" 😄 .  
I hope what i post can reproduce the issues often enough. Lets see. Will try to post it today.

---

<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: [9 July 2025 09:11 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/7 "2025-07-09T09:11:22Z")

</div>

Were you able to replicate the issue?

---

<div class="post-metadata">

### Author: ![SandeepA](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandeepa/32/63225_2.png) [@SandeepA](https://discourse.nodered.org/u/SandeepA)
#### Post date: [11 July 2025 13:45 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/8 "2025-07-11T13:45:48Z")

</div>

Unable to create a reproducible flow ☹ .  
I see it happening in my flows though.

If something comes will open the thread again.

---

<div class="post-metadata">

### Author: ![SandeepA](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sandeepa/32/63225_2.png) [@SandeepA](https://discourse.nodered.org/u/SandeepA)
#### Post date: [11 July 2025 14:37 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/9 "2025-07-11T14:37:21Z")

</div>

Ok. I think i managed to play with it - and "somewhat" understand the situation.

1. I am using most of my groups as displayed/shown via. ui-control.

2. The issue seems to be a race condition.

3. I have part of the flow (lets say part 1) to inject msg.payload to UI Control to display the group.

4. I have part of the flow (lets say part 2) running in parallel. It prepares. msg.payload and msg.ui\_update (for widget definition) and injects to widget (sitting on that group)

5. Depending on which part of the flow gets executed first - i see /dont see the issue.

6. If part 1 to display ui\_control gets executed first then its all good. part 2 gets executed with delay and shows data on the widget.

7. If part 2 (data prep + widget creation) gets executed first , and then part 1 to display widget gets executed - the data doesnt get displayed.

My guess is when we display a group via. ui control - it discards the data on the widget.

I am still playing to understand if indeed this is the situation for all my flows. So more may come.

---

<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: [10 August 2025 14:37 UTC](https://discourse.nodered.org/t/dynamically-creating-widgets-with-payload-in-same-msg-payload-is-not-always-reflected/97966/10 "2025-08-10T14:37:29Z")

</div>

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