Your expected behavior is not correct since you are not updating/modifying the fact after you change one of its properties. By default Drools doesn't know when a fact is modified so you have to explicitly let him know by using the modify() automagic function.

Best Regards  

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com


On Mon, Oct 29, 2012 at 11:59 PM, kina06 <reachkn6@gmail.com> wrote:
I have inserted 3 accounts into knowledge session with the following account
statuses 1-NEW, 2-TRANSFER,3-CLOSE.

EXPECTED BEHAVIOR:
As per below given rules, first rule should change all of them to 'pending'
status, so second rule should never fire and third rule always fire for
above 3 accounts.

ACTUAL BEHAVIOR:
second rule is fired for account with new status, i.e. the first one, but in
the system out its status is shown as PENDING before i set it to ERROR.

Can't figure out what's wrong with this, does it has to do anything with
MVEL vs JAVA usage? I mean in when claues it's mvel and in then clause it's
java, so is that causing problem?


rule "Rule1"
salience -1
when
        account : Account();
then
    System.out.println("Ac state rule1 before change "+
account.getAccountStatus());
      account.setAccountStatus( "PENDING" );
      System.out.println("Ac state rule1 after change "+
account.getAccountStatus());
end


rule "Rule2"
salience -2
     when
         account : Account(StringUtils.equals(accountStatus,"NEW"))
         then
            System.out.println("Ac state RuleNo2 before change "+
account.getAccountStatus());
         account.setAccountStatus("ERROR");
         System.out.println("Ac state RuleNo2 after change "+
account.getAccountStatus());
end

rule "Rule3"
salience -3
     when
         account : Account(StringUtils.equals(accountStatus,"PENDING"))
         then
            System.out.println("Ac state  "+ account.getAccountStatus()+ ".
YES
this is expected");
end



--
View this message in context: http://drools.46999.n3.nabble.com/Field-value-is-different-when-and-then-section-very-strange-Is-it-mvel-vs-java-issue-tp4020550.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users