Hi!
I'm trying to use the accumulate function in my rules, but I haven't the expected result. this is my rule:
rule "Total days"
when
$mo: MyObject()
$total : Number() from accumulate(Item(item=="days", $val:value) from $mo.items, sum( $val ) )
then
System.out.println($total);
end
Suppose that tha values of MyObject(id, arrayList<Item> items) are:
MyObject(id=1, items({price,10},{days,2});
MyObject(id=2, items({price,15},{days,5});
MyObject(id=3, items({price,20},{days,7});
the result should be 2+5+7 = 14 but instead it print me 3 value:
2
5
7
.... where I wrong? I want the sum of the days...!
please help me..!
thank you!