# LINK call broken?

**URL:** https://discourse.nodered.org/t/link-call-broken/92897
**Category:** General
**Created:** [4 November 2024 10:33 UTC](https://discourse.nodered.org/t/link-call-broken/92897 "2024-11-04T10:33:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)
#### Post date: [4 November 2024 10:33 UTC](https://discourse.nodered.org/t/link-call-broken/92897/1 "2024-11-04T10:33:15Z")

</div>

Hello  
I set up my flow using link call node, but it doesnt work, and i am constantly getting error msg.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d47418800b06e8508eadd237370e6f27448361dc.png)

Here is my setup. Where is the problem?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e14099e02f086d16833f5b830557dd03503896f5.png)

UPDATE:  
I think the problem will be with the function..but i dont know why???

This is the function

```auto
if (msg.payload === true) {
    msg = {
        "ui_update": {
            "icon": "mdi-lightbulb-on-10",
            "iconColor":"black",
            "buttonColor":"yellow"
        },
        "payload":true,
        "deviceid":msg.deviceid,

    };

} else {
   
    msg = {
        "ui_update": {
            "icon": "mdi-lightbulb-outline",
            "iconColor": "black",
            "buttonColor": "grey"
        },
        "payload": false,
        "deviceid": msg.deviceid,
    };

}

```

---

<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 November 2024 10:52 UTC](https://discourse.nodered.org/t/link-call-broken/92897/2 "2024-11-04T10:52:44Z")

</div>

> [@GIGS1975](#):
>
> I think the problem will be with the function..but i dont know why???

You are generating a brand new `msg` in your function and therefore discarding the important data that tells the link-call and link-out to route the msg.

instead of setting `msg = { ... } `, just update the properties of the incoming e.g. `msg.payload = ...` so that the important stuff required by the link-call is left in tact.

---

<div class="post-metadata">

### Author: ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)
#### Post date: [4 November 2024 10:59 UTC](https://discourse.nodered.org/t/link-call-broken/92897/3 "2024-11-04T10:59:57Z")

</div>

```auto
if (msg.payload === true) {
    
    msg.ui_update.icon = "mdi-lightbulb-on-10";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "yellow";
    msg.payload = true;
    msg.deviceid = msg.deviceid;
     

} else {
   

    msg.ui_update.icon = "mdi-lightbulb-outline";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "grey";
    msg.payload = false;
    msg.deviceid = msg.deviceid;

}

return msg;

```

I tried this one..  
But now the Dashboard can not update the button..

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/feca077bb0e221e4c97c8f1c89b25c6ed25226aa.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 November 2024 11:02 UTC](https://discourse.nodered.org/t/link-call-broken/92897/4 "2024-11-04T11:02:30Z")

</div>

As the message says, it cannot update something that is undefined. i.e. the things JUST BEFORE `.icon` - so make it "something" before you try to populate it.

```auto
if (msg.payload === true) {
    
    msg.ui_update = {}
    msg.ui_update.icon = "mdi-lightbulb-on-10";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "yellow";
    msg.payload = true;
    msg.deviceid = msg.deviceid;
     

} else {
   
    msg.ui_update = {}
    msg.ui_update.icon = "mdi-lightbulb-outline";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "grey";
    msg.payload = false;
    msg.deviceid = msg.deviceid;

}

return msg;

```

NOTE: this is far easier in a change node.

---

<div class="post-metadata">

### Author: ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)
#### Post date: [4 November 2024 11:04 UTC](https://discourse.nodered.org/t/link-call-broken/92897/5 "2024-11-04T11:04:00Z")

</div>

> [@Steve-Mcl](#):
>
> `msg.ui_update = {}`

Thank you for the help, and the suggestions. It works now

---

<div class="post-metadata">

### Author: ![GIGS1975](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gigs1975/32/47306_2.png) [@GIGS1975](https://discourse.nodered.org/u/GIGS1975)
#### Post date: [4 November 2024 11:05 UTC](https://discourse.nodered.org/t/link-call-broken/92897/6 "2024-11-04T11:05:36Z")

</div>

With change node i would need to use another switch node, to differenciate true and false incoming payload, so thats why i thought i can do it in one place.

---

<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 November 2024 11:13 UTC](https://discourse.nodered.org/t/link-call-broken/92897/7 "2024-11-04T11:13:10Z")

</div>

Of course you can, but you lose the essence of what a visual flow designer is!

---

<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: [18 November 2024 11:14 UTC](https://discourse.nodered.org/t/link-call-broken/92897/8 "2024-11-18T11:14:04Z")

</div>

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