Writing a groov table with a single node

Instead of looping through the values you do have, I would recommend looping through all 40 and only write the defined values, otherwise write a placeholder like zero. That way the first 13 (or however many values) will get written and the last 27 still get written to, they just get overwritten with zero instead of some other value.

To make this dynamic and avoid the split node, you can just use node.send({payload : ...}) and an if statement to check to see that the value is good.
Also, note that this node.send() returns individual payloads, so there’s no need for a return statement at the end of the code.

for(i = 0; i < 40; i++) {
// If this value exists, write it to the list:
if(typeof(msg.payload.Classes[i]) !== "undefined") {
    node.send({ payload: { tagName : 'id',
                tableStartIndex : i,
                value : msg.payload.Classes[i] }});
}
// Write zero for undefined values and values not provided by the payload:
else node.send({ payload: { tagName : 'id',
                tableStartIndex : i,
                value : 0 }});
}

So this would exist right after your “Join” function node and would not rely on a split node.
@nickvnlr do you think this is the kind of approach that you’re looking for?

1 Like