Function Note TypeError

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

HI @tirosh_gutte,

I took a look at your workflows and it looks like you are seeing this problem as the data coming in is not in the same format. The data coming in to the Webhook has the entire payload as one key with an empty string as the value:
44%20AM

When your Function Node is looking for {{data.body.data}}, it is not finding anything, as the payload that is coming in is being recognized as a key, not multiple keys with multiple values. It looks as though the Webhook is sending data in this format, so be sure to check how you have it set up!

26%20AM

Thanks,
Julia