I need to get the total price of the order in Dataweave.
<?xml version='1.0' encoding='UTF-8'?>
<Orders>
<Order id="10001">
<ProductId id="P001">P-001</ProductId>
<ProductName>Samsung 40Inch TV</ProductName>
<Category id="C001">Samsung TV</Category>
<Price>399</Price>
<Quantity>5</Quantity>
</Order>
<Order id="10001">
<ProductId id="P002">P-002</ProductId>
<ProductName>Samsung 32Inch TV</ProductName>
<Category id="C001">Samsung TV</Category>
<Price>299</Price>
<Quantity>5</Quantity>
</Order>
</Orders>
I've tried the following dataweave without success:
%dw 2.0
output application/json
---
{
"totalCost": sum(payload.Orders.*Order.Price)
}