user3407479
user3407479

Reputation: 287

Mule ESB DataMapper: Aggregation of field 1 multiplied by field 2

I have the following structures:

Strcuture A:

<itemlist>
  <item>
    <id>123</id>
    <price>1</price>
    <quantity>1</quantity>
  </item>
  <item>
    <id>124</id>
    <price>2</price>
    <quantity>1</quantity>
  </item>
  <item>
    <id>125</id>
    <price>3</price>
    <quantity>1</quantity>
  </item>
<itemlist>

Structure B:

<totals>
  <total>
    <totalPrice>3</totalPrice>
  </total>
</totals>

If I want a sumation of all the field multiplied by the field in structure A to be placed into the totalprice field of structure B, would that be possible in the DataMapper.

If it is possible, how would you do it?

Thanks

Upvotes: 1

Views: 35

Answers (1)

V&#237;ctor Romero
V&#237;ctor Romero

Reputation: 5115

Yes it is, in datamapper find the mapping of the field 1 and then go to script view. There you will find a datamapper MEL script. Find output.total = input.field1 and add * input.field2.

Upvotes: 1

Related Questions