I new to mulesoft and have written dataweave for iterating over orderline item(product-lineitem in xml). However, its not working, it only inserting one order line item, (order line item -product-lineitem) Any pointers?
Input
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns="http://www.demandware.com/xml/impex/order/2006-10-31" order-no="00001101">
<order-date>2020-07-09T12:55:28.663Z</order-date>
<original-order-no>00001101</original-order-no>
<product-lineitems>
<product-lineitem>
<product-id>65754</product-id>
</product-lineitem>
<product-lineitem>
<product-id>65755</product-id>
</product-lineitem>
</product-lineitems>
</order>
Dataweave
%dw 2.0
output application/java
ns ns0 http://www.demandware.com/xml/impex/order/2006-10-31
---
[{
Order_Confirmation_Number__c: payload.ns0#order.ns0#"current-order-no",
"attributes": {
"type": "PBSI__PBSI_Sales_Order__c",
"referenceId": "SO"
},
"PBSI__Sales_Order_Lines__r": {
"records": payload.*ns0#order.ns0#"product-lineitems" map((e,empindex) -> {
"attributes": {
"type": "PBSI__PBSI_Sales_Order_Line__c",
"referenceId": "SOL"
},
"PBSI__Item__c": "a0a1x000001PfWa",
"PBSI__ItemDescription__c": e.ns0#"product-lineitem".ns0#"product-id"
})
}
}]