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.<div>
<br></div><div>Best Regards <br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Mon, Oct 29, 2012 at 11:59 PM, kina06 <span dir="ltr"><<a href="mailto:reachkn6@gmail.com" target="_blank">reachkn6@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have inserted 3 accounts into knowledge session with the following account<br>
statuses 1-NEW, 2-TRANSFER,3-CLOSE.<br>
<br>
EXPECTED BEHAVIOR:<br>
As per below given rules, first rule should change all of them to 'pending'<br>
status, so second rule should never fire and third rule always fire for<br>
above 3 accounts.<br>
<br>
ACTUAL BEHAVIOR:<br>
second rule is fired for account with new status, i.e. the first one, but in<br>
the system out its status is shown as PENDING before i set it to ERROR.<br>
<br>
Can't figure out what's wrong with this, does it has to do anything with<br>
MVEL vs JAVA usage? I mean in when claues it's mvel and in then clause it's<br>
java, so is that causing problem?<br>
<br>
<br>
rule "Rule1"<br>
salience -1<br>
when<br>
account : Account();<br>
then<br>
System.out.println("Ac state rule1 before change "+<br>
account.getAccountStatus());<br>
account.setAccountStatus( "PENDING" );<br>
System.out.println("Ac state rule1 after change "+<br>
account.getAccountStatus());<br>
end<br>
<br>
<br>
rule "Rule2"<br>
salience -2<br>
when<br>
account : Account(StringUtils.equals(accountStatus,"NEW"))<br>
then<br>
System.out.println("Ac state RuleNo2 before change "+<br>
account.getAccountStatus());<br>
account.setAccountStatus("ERROR");<br>
System.out.println("Ac state RuleNo2 after change "+<br>
account.getAccountStatus());<br>
end<br>
<br>
rule "Rule3"<br>
salience -3<br>
when<br>
account : Account(StringUtils.equals(accountStatus,"PENDING"))<br>
then<br>
System.out.println("Ac state "+ account.getAccountStatus()+ ".<br>
YES<br>
this is expected");<br>
end<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Field-value-is-different-when-and-then-section-very-strange-Is-it-mvel-vs-java-issue-tp4020550.html" target="_blank">http://drools.46999.n3.nabble.com/Field-value-is-different-when-and-then-section-very-strange-Is-it-mvel-vs-java-issue-tp4020550.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>