Red Hat Bugzilla – Bug 742921
Dependent enumerations not working in Business Rules
Last modified: 2016-07-31 21:12:13 EDT
Description of problem:
Dependent enumerations are not working in Business rules - Guided editor. Instead of a drop-down list with the dependent values, only an editable text box is shown.
'fact.f1' : ['a','b']
'fact.f2[f1=a]' : ['a1', 'a2']
'fact.f2[f1=b]' : ['b1', 'b2']
The screenshot shows the rule.
Version-Release number of selected component (if applicable):
BRMS 5.2.0 ER5
In Test Scenarios, dependent enumerations seem to work just fine.
After playing a bit with test scenarios, I found out that:
If you insert a given fact (see above for the model and enumeration),
- any enum value you want has to be first selected, otherwise, Guvnor thinks it's null. This means, for the "default" value in the dropdown, you have to select something else and then select the default again. You have to confirm your choice by saving the test scenario.
- the depending enum value works the same as above. The dropdown list with the correct values is shown after "correctly" selecting and confirming the first value (the one it depends on).
- save, save again and save... makes it safe to use ;) Using Facts with enumerations the above mentioned way makes it work, the right rules are fired.
Even if the dependent enumerations don't work in business rules, you can type the appropriate field value into the dependent field edit box. You just have to know what you want in there...
BTW, there is no screenshot attached, as you suggest there is.
Created attachment 527624 [details]
rule with a dependent enumeration
Sorry, forgot to post it, though it's a really simple rule anyway.
Green rectangle shows the basic enum, that works fine. Orange rect. is the dependent enum - only 'b1' or 'b2' should be allowed in there...
I added the dependent field after choosing value for the first field.
No problem, I guessed as much. I've fixed what you reported here, but I notice another issue - in Test Scenarios if you change the value of the parent dependent enum (f1, in your example) the options for f2 do not update - you need to delete f2 and re-add it. To prevent this BZ becoming an umbrella for other issues, can you please create a new ticket for this behaviour (and take it through the 5.3 triage process)?
Thanks. I think the issue you mentioned has already been reported somewhere, hence why I didn't look into it too much. I'll do a search and make a new BZ if I can't find it.
Technical note added. If any revisions are required, please edit the "Technical Notes" field
accordingly. All revisions will be proofread by the Engineering Content Services team.
When using the guided template editor to add a rule that uses dependent enumeration instead of being able to select from a drop down menu an editable plain textbox was provided. An enumeration drop down menu has been added to resolve the issue.
This bug seems to be present in kie-drools-wb-distribution-wars-6.1.0.Final-tomcat7.0.war
It seems that it does not work if the enumeration is defined like this:
'fact.f2[ f1=a ]' : ['a1', 'a2']
Notice the " "(blank space) between "f2[" and "f1=a"
The documentation uses blank spaces in the examples: http://docs.jboss.org/drools/release/6.1.0.Final/drools-docs/html_single/index.html#drools.AdvancedEnumConcepts