on 2021 Jun 29 7:11 AM
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...
Request clarification before answering.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.