Search code examples
drools

Drools compare two objects in decision table


I have the following code in DRL file

rule "MyExample"
when
    $eentity : ExampleEntity()
    $sentity : SecondEntity( secondField == $eentity.getMainField())
then
    System.out.println(true);

end

This is works but I need to convert it to spreadsheet table. I tried so much variants but no one works. How can I write this rule in decision table?


Solution

  • Use a single condition column:

    CONDITION
    ExampleEntity($mf: mainField) SecondEntity
    secondField == $mf /*param*/
    Combine Ex with Sec on equal field values
    x
    

    The /*param*/ and the x is a hack to get the condition being generated for the row.