Forum Discussion
Hi,
If you put this mammoth of an expression 🙂 in a Mapper:
$TOTLITEM.item.map( (item, pos, a)=>item.extend({DETAILS: (pos != 0) ? sl.ensureArray( {}.extend({LINE:1,WORK:$REFILL.item[pos].WORK}) ) : sl.ensureArray( {}.extend({LINE:1,WORK:$REFILL.item[pos].WORK}) ).concat({}.extend({LINE:2,WORK:$REFILL.item[pos].WORK})) } ) )
and you assign it to the $TOTLITEM.item Target Path, then you will get the expected output.
There’s that. Now, this solution is static, in the sense that it exactly transforms the input into the output. That’s because without knowing the size of the nested array $DETAILS in advance, not much more can be done. But then, I feel that the solution wouldn’t be so compact, in the sense that it will more than likely require a few more snaps for the transformation to be proper.
Let me know if you have any other questions.
Cheers,
Dimitri