Hello everyone.
I’m trying to read each item in the Loop For on Code node and have no idea how to reffer the index.
Example:
In the image i have 2 json from the previously node. Each one with a recurrency_number field and a Status Field.
I want to set a variable for each recurrency_number, when status is COMPLETE, the value will be true.
The code i’m working now:
rec1 = false;
rec2 = false;
rec3 = false;
for (const item of $input.all()) {
if($item("0").$node["HM - Subs Purchases"].json["status"] === "APPROVED" || $item("0").$node["HM - Subs Purchases"].json["status"] === "COMPLETE")
{
if($item("0").$node["HM - Subs Purchases"].json["recurrency_number"] === 1) {
rec1 = true;
}
if($item("0").$node["HM - Subs Purchases"].json["recurrency_number"] === 2) {
rec2 = true;
}
if($item("0").$node["HM - Subs Purchases"].json["recurrency_number"] === 3) {
rec3 = true;
}
}
}
return [{
rec1,
rec2,
rec3}]
I tried $item(RunIndex), $item(item) and doens’t works. &itrem(“0”) only will set the recurrency for the first json structure.