Have received the following error running node:
FunctionNodeTypeError
Cannot read property ‘substring’ of undefined
at customFunction (RawFunctionNode:2:39)
Been using the same function (javascript) for two identical workflows (one workflow per device, one trigger URL per device). One workflow is working properly, the other provide this error message.
Java Script in the Function Node:
var fullString=payload.data.body.data;
var x=parseInt(payload.data.body.data.substring(4, 6),16);
payload.data.body.ChaNum1=parseInt(fullString.substring(1, 2),16);
payload.data.body.ChaNum2=parseInt(fullString.substring(3, 4),16);
if(x==43){
payload.data.body.Sign=1;
}else if(x=45){
payload.data.body.Sign=-1;
}
payload.data.body.Sign=parseInt(fullString.substring(4, 6),16);
payload.data.body.Par1=parseInt(fullString.substring(7, 8),16);
payload.data.body.Par2=parseInt(fullString.substring(9, 10),16);
payload.data.body.Par3=parseInt(fullString.substring(11, 12),16);
payload.data.body.Par4=parseInt(fullString.substring(13, 14),16);
payload.data.body.Par5=parseInt(fullString.substring(15, 16),16);
payload.data.body.Par6=parseInt(fullString.substring(17, 18),16);
payload.data.body.Par7=parseInt(fullString.substring(19, 20),16);
payload.data.body.Par8=parseInt(fullString.substring(21, 22),16);
payload.data.body.Digin=parseInt(fullString.substring(23, 24),16);
payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2;
payload.data.body.ValueTot=payload.data.body.Sign*(payload.data.body.Par1+payload.data.body.Par2+payload.data.body.Par3+payload.data.body.Par4+payload.data.body.Par5+payload.data.body.Par6+payload.data.body.Par7+payload.data.body.Par8);
The Workflow look like this:
Please assist