Hello,
I nedd to read from an array of object the row that in my example is (20). I would like to select the row with an external numeric variable from 0 to 237.
Thanks for the help,
Hello,
I nedd to read from an array of object the row that in my example is (20). I would like to select the row with an external numeric variable from 0 to 237.
Thanks for the help,
You can pass the number of interest in any msg
property you want & use a function or change node to grab the item...
in a function...
msg.item = msg.payload[msg.index];
return msg;
or in a change node using jsonata SET item
TO payload[index]
Demo flow to import and try out...
[{"id":"c1093799.d30798","type":"inject","z":"bec69dbd.8d622","name":"index 6","props":[{"p":"index","v":"6","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":600,"wires":[["400bb107.9c021"]]},{"id":"522288e7.1fc248","type":"debug","z":"bec69dbd.8d622","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"item","statusType":"msg","x":690,"y":600,"wires":[]},{"id":"400bb107.9c021","type":"change","z":"bec69dbd.8d622","name":"get data","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"string 1\",\"string 2\",\"string 3\",\"string 4\",\"string 5\",\"string 6\",\"string 7\",\"string 8\",\"string 9\",\"string 10\",\"string 11\",\"string 12\",\"string 13\",\"string 14\",\"string 15\",\"string 16\",\"string 17\",\"string 18\",\"string 19\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":600,"wires":[["7287c163.e1905"]]},{"id":"1565c0e.702173f","type":"inject","z":"bec69dbd.8d622","name":"index 9","props":[{"p":"index","v":"9","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":640,"wires":[["400bb107.9c021"]]},{"id":"d20e1301.d62e4","type":"inject","z":"bec69dbd.8d622","name":"index 12","props":[{"p":"index","v":"12","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":680,"wires":[["400bb107.9c021"]]},{"id":"7287c163.e1905","type":"function","z":"bec69dbd.8d622","name":"get item by index","func":"msg.item = msg.payload[msg.index]\nreturn msg;","outputs":1,"initialize":"","finalize":"","x":510,"y":600,"wires":[["522288e7.1fc248"]]}]
Thanks for you support Steve.
In my case, how can pass the number of external variable to index ?
To be more clear, I would like to ingect an extern nuber, and select the richt row from my array.
Thanks for the support,
thats what my demo flow does.
Thanks I read after my last reply.....
HI Steve,
If I received the value of index, not from an inject fix value, but from an array in position 0 I try to wite the following code, but nothing happen,,,,
var data=msg.payload;
var indice=data[0];
msg.index=indice;
return msg;
You will need to share your flow, you have not provided enough information to help you.
I had a mystake about the index max of number of row...
Thanks a lot for your support,
Regards,
Marco
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.