[rules-users] How do I reference newly asserted facts?

kissro at lidp.com kissro at lidp.com
Mon Dec 10 10:08:30 EST 2007


Hello,

I am creating all my rules using the BRMS guided rule editor gui.
In the rule editor, I have a rule that looks like this:

WHEN
      FNAC_CLIENT_CONTROL
  FNAC_BIRTH_PLACE is equal to "IL"

THEN
  Assert FNCM_COMMENT FNCM_VARIABLE_DATA "This client lives in Illinois"

When I click the 'View Source' button I see this:

rule "Rule500"
   dialect "mvel"
   when
         FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
   then
         FNCM_COMMENT fact0 = new FNCM_COMMENT();
         fact0.setFNCM_VARIABLE_DATA( "This client lives in Illinois");
         insert( fact0 );
end

After I return from "fireAllRules", how do I reference the newly
asserted fact in my Java code?  Do I reference "fact0" or can I use the
object's "real" name - FNCM_COMMENT.FNCM_VARIABLE_DATA?

"fact0" is just a generated name created by BRMS when it generates the
rule based on what I type in the gui, right?  I'm assuming if I insert
more facts, they would be called fact1, fact2, etc.  If I want to
reference these facts, do I have to keep track of how many I've inserted
then reference the appropriate fact number?  I'm not sure how to
reference these generated fact names after returning from the rule
engine.  Could someone help me?

Thanks,
Rod  



More information about the rules-users mailing list