Switch Node using substring – Stack Overflow
Struggling with what should be a simple query in a node-red Switch node. Want to anayyse the incoming string and then switch based on the value of the character at position 4 (if 1 then output 1, if 2 output 2 etc).
I have tried with property set to msg.payload.substring (3,4) and then ==1, ==2 etc but there is no debug output.
If I change to a java expression payload.$substring(3,4) or just $substring(3,4) then debug shows
Invalid JSONata expression: Attempted to invoke a non-function. Did you mean $substring
I need the entire payload to emerge from the Switch node, rather than just the single test character.
I am obviously doing something silly, any help appreciated.
[{"id":"32a26e54.6cb122","type":"switch","z":"a503303b.a0ce58","name":"Determine Sensor Type","property":"payload.substring(3, 4)","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":410,"y":40,"wires":[["3c9ebe7f.9b7962"],[],[]]}]
Read more here: Source link
