Load value into function

I would like to write a function, when initiated by "PLC start mission", will take the value from "robot_id" and enter it in the appropriate place in the function. Unfortunately, he keeps throwing me an error. Anyone tell me how to correctly load a value into my function?


Hi @Pikny.

Can you use debug nodes after your Switch and robot_id nodes to show us what's arriving at the Function?

It would be good to see the actual error message you get too.

Hello, if you want to get help, please, answer questions from forum...

Hi jbudd.

I apologize for the late response.
I improved my flow.

All the time I have a problem with load number of robot_id in the function node. Robot_id is "undefined".
How I should define this variable correctly?

I will be grateful for your tips and help.

This is example value model from documentation:


and the values, which I would like to use:


Your robot id is in msg.payload not msg.payload.robot_id_int



Additionally, looking at your flow, I suspect you think these 2 messages will arrive into the function at the same time. They will not! This is a fundamental point to understand if you are to be proficient with node-red.


For this you would need to store the robot ID in context or use a join node.

to avoid mistakes like these, it would be worth spending a little time learning the basics...

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Thank you for your activity.
I watched this playlist and I understood some problematic topics.
I solved my problem.

Best regards!