I have the same "problem", but eval(objectList == null) doesn't work. If I don't execute "drools.getWorkingMemory().setGlobal()" it "works fine", as if the rule activates and the object is null.

global List objectList;

rule "Start"
   salience 101
   when
       #conditions
   then
       objectList = new ArrayList() ;
       objectList.add("1");
objectList.add("2"); System.out.println("Start objectList:"+objectList); //drools.getWorkingMemory().setGlobal("objectList", objectList);
end

rule "end"
   salience 97
   when
       eval (objectList == null)
   then
       System.out.println("End objectList: "+objectList);
end
gives: Start objectList:[1, 2]
   End objectList: null

Next I uncomment the "drools.getWorkingMemory().setGlobal("objectList", objectList);" and run the rule again an get:

   Start objectList:[1, 2]
   End objectList: [1, 2]

so the objectList isn't null, but the rule still activates...

Kris Verlaenen schreef:
That initialized my global but the rule still runs every execution. Can I
disable the rule after the first execution?
What do you mean by "every execution". A rule should only be executed once, unless it gets reactivated (which should not be the case in this situation).

I would like to use (if (objectList==null)). My list is not immutable. Can
I make a similar rule for the LHS?
You can test whether the global is null using eval( objectList == null ) in the LHS of the rule.

Kris
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to