Hello everyone!
I'm trying to do a transformation in an array object and I'm get stucked. Can anyone help me to figure it out ?
I'm aware that the better solution is doing the "denormalization" of this array as @Joe_Fleming said in another topic, but, unfortunately, it can't be done right now. (read about it here
the evil object
painless script that isn't working and are giving me a headache.
def l = new ArrayList();
if(!doc.containsKey('details.plan_op_nature')){return 0;}else{
for(int i = 0;i<doc['details.plan_orders'].values.length;i++){
l.add(doc['details.plan_orders_product_quantity'].values[i]);
}
return sum(l);
}
The desired result when doc contains the field plan_op_nature:
the sum of all objects in the array l (in the case of the image, it should be 15000)
Thx a lot for your time!
