cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Promotion Condition compairing two RAO values

janbu
Explorer
0 Kudos
257

I am currently trying to create a promotion rule that compares two lists in the orderRao object to determine if the rule should be executed anymore. I'm using a RuleIrAttributeRelCondition to achieve this, but it not really works. What is the proper way of doing that?


My code so far:

@Overridepublic RuleIrCondition translate(RuleCompilerContext context,RuleConditionData condition,RuleConditionDefinitionData ruleConditionDefinitionData) {
var orderRao = context.generateVariable(OrderRAO.class);
RuleIrAttributeRelCondition maxNumberOfCouponsCondition =
RuleIrAttributeRelConditionBuilder.newAttributeRelationConditionFor(orderRao)
.withAttribute("discountValues.size()")
.withOperator(RuleIrAttributeOperator.LESS_THAN_OR_EQUAL)
.withTargetAttribute(orderRao)
.withTargetVariable("coupons.size()")
.build();
return maxNumberOfCouponsCondition;
}

Generated Drools rule (part):

when
(
exists (CouponRAO(couponId == "FANCY-COUPON-CODE"))
and
$rao_v5 := OrderRAO(discountValues.size() <= $rao_v5.coupons.size())
)

But the rule is never true...

Accepted Solutions (0)

Answers (0)