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;
{
"id": "cahuccj3cf1scmmfcc4uqmjwgt",
"payload": 1668877379280
}
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.
Function Node
There is a special node in Robomotion where you can manipulate this object with Javascript.
The Function node is used to write Javascript inside your flows.
This function adds my_new_field to the msg object. Function node should always return the msg object;
Debug node
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;
What if you have a file that has today's date in its name but is in a fixed folder? Here you can use a simple Javascript as below;
var date = new Date().toISOString().split("T")[0];
// 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;