Missing varibale binding in Drools
I am using kie workbench's 6.2 guided decision table and I am stuck with the following scenario
I want to set the promocode in promotion only if the PromoCode from EligibilityCriteria is checked against the some values in the rule. like shown below in code generated by workbench from the decision table
//from row number: 1
rule "Row 1 test"
dialect "mvel"
when
$e : EligibilityCriteria( $code : PromoCode in ( "code1", "code2" ) , $make : vehMake == "BMW" )
then
Promotion p = new Promotion();
p.setPromoId("123");
p.setPromoCode($code);
insertLogical( p );
end
If no value is specified for the promocode on the text box on guided decision table the generated does not creates the variable $code and the code fails since $code is not created
//from row number: 1
rule "Row 1 test"
dialect "mvel"
when
$e : EligibilityCriteria($make : vehMake == "BMW" )
then
Promotion p = new Promotion();
p.setPromoId("123");
p.setPromoCode($code);
insertLogical( p );
end
I just want to somehow indicate whether the rule field for promocode is empty or it has some value.
Responses
Hi Ashish
If you have a support subscription with us please raise a case for this so one of our B*MS engineers can take a look at this. I'm no expert in this field but I presume you want to setPromoCode only if PromoCode is present - so you could check for PromoCode is provided before attempting to use it.
Take a look at section 2.1.1 here: https://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/
I don't know if that will help but I hope you get an idea of what I'm getting at. Like I said, the best thing would be to raise a case to get the best advice on how to accomplish this.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
