I am a little bit confused about the rules fact variables and process variables relationship. I have a process with variables: name:String, age:Integer, access:Boolean. I would like to verify with a business rule if the variable age is less than 18 then the access would be set to false. I created a model called User with these fields. The rule separately works fine, but I am inserting a User object in ksession. If I am using a process model like this:1.Human Task, 2 Business rule, 3.Human task, how can I set these values or what is the relation ship exactly between my process variables and rule template data?
Should I use the rule template as a variable in my process? If yes please let me know how it is possible.
Note: The fields: name, age are filled in runtime by a user.
Thank you in advance.
Kind regards, Hunor-Attila Kerekes
You can access process variables from rules so I believe that would work for your case. Just make sure you insert process instance as a fact into the session so you can then access it and its variables.
import org.drools.runtime.process.WorkflowProcessInstance rule "your rule" when p: WorkflowProcessInstance() then System.out.println("Variable is " + p.getVariable("yourVar")); end