Product Features
...
Analytics
Statistical Functions
JavaScript Processor
3min
this processor function enables users to use javascript as a programming language for manipulating and managing data coming from input tags javascript overview this processor uses javascript scripting simple use case the output you receive from devicehub message or from analytics, might not be helpful, and you want to change the name of a field within that message in general, if you want to add, remove or modify any field in the input, this scripting processor is very useful e g instead of "value" you want your data to show "furnace pressure" e g instead of having all fields of the message, you only want to have "success", "deviceid" and "value" and skip everything else e g you want to add a custom field to the message, based on the "value" field, such as if value = 2, "error" "overheating" e g you only want to change the timestamp to human readable format instead of unix timestamp, but keep otherwise keep the message as it is single input every message from the input, is stored as an array called "values" using "for i, message in values{}" statement, allows to access this input and manipulate it here "i" represents what is the definition defined in the connection wire, more useful for multi inputs, to identify and distinguish between each inputs, so for single input, "i" can be replaced with " " "message" contains the entire message in the input, and you can perform your manipulations to this "message" parameter note "i" and "message" can be any custom variable name multiple input suppose you have 3 different inputs attached to this scripting processor, with the connecting wires named a, b and c "for i, message in values{}" will now have 3 inputs "i" represents from which connection wire is the input coming from with if else statements, every input can be manipulated in isolation, or a common manipulation can be applied to all inputs you can choose to output "result" only for one input, or all of the inputs javascript parameters parameters details text editor write the javascript code you want to execute learn more here note when creating an analytics flow with javascript processor processor, refer the use the javascript processor function docid\ ingtsivg5iq flczlhxws guide for more details