droolsdrools-guvnordrools-flow

Drools Workbench - Compare common attribute from different objects


Does anyone know how to add a condition on drools workbench for comparing attributes with the same name but from different objects (like their IDs) ?

Workbench screenshot

What I want to add is a 3rd condition like "l.ID = o.ID". If the facts do not have the same ID, it does not print "login". I cannot find a way to do it.

Any help will be appreciated.

Cheers,


Solution

  • I've found a possible solution.

    id match

    You need to bound the "ID" attribute of the 1st object to a variable and then compare the same attribute of the 2nd object ("ID") with the created variable. It was hard to get here because, in the first "WHEN" clause, the GUI is misleading: "--- please choose ---" is not mandatory, and it will only work if no option is selected.

    This seems to do trick, but if everyone knows other (i.e., better) solutions. Feel free to post them.

    Cheers,