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

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 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?

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

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

   // 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:

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

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

Strange. Does this flow work if you Import it?

[{"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":[[]]}]

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"

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.

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

and it throws:

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

'help4time' where is this coming from ?

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

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

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

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

Just checked and NO it's a normal function node

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.

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.

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

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

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

And more sophisticated requirements need a modal window popup :smiley:

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