# How to display a "message" from within a flow function

**URL:** https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064
**Category:** General
**Created:** [3 March 2023 15:41 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064 "2023-03-03T15:41:11Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 15:41 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/1 "2023-03-03T15:41:11Z")

</div>

From within a flow js function using a console.log is easy to use. But how to display that message/string to the dashboard display?  
The page [RED.notify : Node-RED](https://nodered.org/docs/api/ui/notifications/) has a line:  
`RED.notify("Hello World");`  
Seems that's not what I need to do, it gives an error "Uncaught ReferenceError: RED is not defined"  
What do I miss here?

---

<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: [3 March 2023 15:55 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/2 "2023-03-03T15:55:02Z")

</div>

Do you mean in a Function node? If so you can use `node.warn("text")` to display in the debug pane.

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 16:09 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/3 "2023-03-03T16:09:53Z")

</div>

Yes, it's within a 'Function node' .  
I'm using this JS code:

```auto
   // help screens
   if (evtCL.contains('helpbtn')) {
      let _id = event.currentTarget.id;
      console.log(" ..... this is help call for :" + _id);
      node.warn(" ..... this is help call for :" + _id);
      return;
   }

```

and it throws:

```auto
..... this is help call for : help4time
VM17056:27 Uncaught ReferenceError: node is not defined

```

So something is missing from 'node.warn'!?

---

<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: [3 March 2023 16:13 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/4 "2023-03-03T16:13:47Z")

</div>

Strange. Does this flow work if you Import it?

```auto
[{"id":"8f5614b664065be8","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":220,"y":620,"wires":[["d20261d7c01ca431"]]},{"id":"d20261d7c01ca431","type":"function","z":"bdd7be38.d3b55","name":"function 18","func":"node.warn(\"hello\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":false},"x":410,"y":620,"wires":[[]]}]

```

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 16:23 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/5 "2023-03-03T16:23:05Z")

</div>

It throws a "hello" on the debug sidebar of the Editor.  
I need a message on the /ui.

Will try the complete part of " Notification with buttons" on the page  
[RED.notify : Node-RED](https://nodered.org/docs/api/ui/notifications/)"

---

<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: [3 March 2023 16:32 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/6 "2023-03-03T16:32:08Z")

</div>

> [@gNeandr](#):
>
> I need a message on the /ui

Ah, sorry, I misunderstood, in fact I still don't understand why node.warn() is not found in a Function node. Is that code actually running in the function node or is it code prepared in a function node that is actually run in the browser? Where exactly does the console.log output appear? In the system console or in the browser developer console?

Are you using node-red-dashboard for the ui? If so then you can send the text to a text node, for example.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [3 March 2023 16:38 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/7 "2023-03-03T16:38:45Z")

</div>

> [@gNeandr](#):
>
> Will try the complete part of " Notification with buttons" on the page  
> [RED.notify : Node-RED](https://nodered.org/docs/api/ui/notifications/)"

This API is only exposed to custom nodes, not to the function node.

> and it throws:

```auto
..... this is help call for : help4time

```

'help4time' where is this coming from ?

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 16:44 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/8 "2023-03-03T16:44:05Z")

</div>

Thanks for your help .. but not finally solved.

To your points:  
-- it's running in a function node  
-- my understanding: it's running in the function node. I have a JS/html/css code which produces some user elements. The idea is to display a "help" message with clicking on an element (button or icon or such)  
-- the console.log goes to the browser developer console  
-- Yes, node-red-dashboard for the ui (would not like to go with a text node, the user should stay with /ui displayed

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 16:46 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/9 "2023-03-03T16:46:21Z")

</div>

> [@bakman2](#):
>
> This API is only exposed to custom nodes, not to the function node.

Please, help with this .. know a function node, but let me understand "custom node"

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [3 March 2023 16:47 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/10 "2023-03-03T16:47:34Z")

</div>

Can you explain in simple terms what you want to accomplish ?

You have a dashboard (at /ui) ? And you want to show a message ?

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 16:49 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/11 "2023-03-03T16:49:33Z")

</div>

Just checked and NO it's a normal function node

---

<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: [3 March 2023 16:50 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/12 "2023-03-03T16:50:54Z")

</div>

> [@gNeandr](#):
>
> the console.log goes to the browser developer console

In that case it is running in the browser, which is why node.warn does not work. If it were running in the server then it would go to the system log.

> [@gNeandr](#):
>
> I have a JS/html/css code which produces some user elements

Not my area of expertise I am afraid, so I will have to leave this to someone else. I think you might have to give some more information about exactly how the js/html/css code does.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [3 March 2023 17:04 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/13 "2023-03-03T17:04:48Z")

</div>

Does the standard dashboard nofication node not do what you need?

---

<div class="post-metadata">

### Author: ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)
#### Post date: [3 March 2023 17:06 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/14 "2023-03-03T17:06:31Z")

</div>

> [@Colin](#):
>
> In that case it is running in the browser,

That's it!  
So the normal JS/html/css code will do it. The most simple would be

```auto
      console.log(" ..... this is help call for :" + _id);
      alert(" ..... this is help call for :" + _id);

```

And more sophisticated requirements need a modal window popup 😃

---

<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: [2 May 2023 17:07 UTC](https://discourse.nodered.org/t/how-to-display-a-message-from-within-a-flow-function/76064/15 "2023-05-02T17:07:27Z")

</div>

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