I am trying to do a for each on a database result set in Dataweave and not able to achieve the result.
Input payload:
{
"x_orders_cursor": [{
"LINE_QTY": 1,
"ORDER_NUMBER": 11820490,
"ORDERED_ITEM": "PAT1M",
"LINE_UOM": "PC"
}, {
"LINE_QTY": 5000,
"ORDER_NUMBER": 11820542,
"ORDERED_ITEM": "ACC62-A-D",
"LINE_NUMBER": 1,
"LINE_UOM": "PC"
}, {
"LINE_QTY": 2000,
"ORDER_NUMBER": 11820542,
"ORDERED_ITEM": "ACC62-A-D",
"LINE_NUMBER": 2,
"LINE_UOM": "PC"
}]
}
Expected Payload:
{
"Orders": [
{
"OrderNum": "11820490",
"Lines": [
{
"LineNum": 1,
"ProductNum": "PAT1M",
"TxnQty": 1,
"TxnQtyUOM": "PC"
}
]
},
{
"OrderNum": "11820542",
"Lines": [
{
"LineNum": 1,
"ProductNum": "ACC62-A-D",
"TxnQty": 1000,
"TxnQtyUOM": "PC"
},
{
"LineNum": 2,
"ProductNum": "ACC62-A-D",
"TxnQty": 2000,
"TxnQtyUOM": "PC"
}
]
}
]
}
Result set is based on a database table that stores both Order Number and Line Number.