What is a Message Object?
Every node in Robomotion processes a message object that is past from a previous node.
A message object is a simple JSON object that looks something like this;
Whenever a msg object is passed to a node, that node manipulates the object, either by adding, deleting or updating fields in the passed object.
This function adds my_new_field to the msg object. Function node should always return the msg object;
You can use Debug node to see what is being passed to the next node. Below you can see the added my_new_field in the Debug output panel.
Where is it used for?
So you have a JSON object that is passed through the flow and updated by the nodes or a Function node, but where is it used for?
The message object can be used to create dynamic values.
As an example, lets say you have an Excel file with a static path like C:\Users\John\Desktop\test.xlsx
You can open this Excel with the Open Excel node by providing this path directly as below;
var date = new Date().toISOString().split("T");
// ex: C:\\Users\\John\\Reports\\2022-11-19.xlsx
msg.path = "C:\\Users\\John\\Reports\\" + date + ".xlsx;
and now you can use this dynamically created path value in Open Excel property as below;