Payload[variable]

Hello,

I am using below code to retrieve data from a payload.

var row = flow.get("row");

msg.payload = msg.payload[row].payload;

return msg;

This is not working. Is there a way to set make the number variabel?
msg.payload[0].payload, msg.payload[1].payload, msg.payload[2].payload, etc.

This works well if:
flow.get("row") gives a number

and
incoming msg.payload carry an array which has that amount of members so it does not look outside of array boundaries

and
incoming msg.payload[the number of the row] has property called with name payload.

If you make sure those conditions are met, It should work flawlessly.
Use debugging options to be sure.

Also such kind of functions should have some fallback for situations when conditions are not met.
Depending on what the real case is but I'd start with easy things like:

var row = flow.get("row")

if(row == undefined){
   row = 0
}

Thanks!
the value had to changed to a number, that did the trick

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.