<div class="gmail_quote"><div>Thanks for your fast response Kris and Michal!<br><br>I tried to use your solution Kris, but I&#39;ve found that 5.0.0 M5 WorkflowProcessInstance does not seems to provide getVariable method. I&#39;ve found that method into WorkflowProcessInstanceImpl searching in svn trunk. I must work with that class or I missed something? Thanks again!<br>
<br>Ricardo.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">---------- Mensaje reenviado ----------<br>From: Kris Verlaenen &lt;<a href="mailto:Kris.Verlaenen@cs.kuleuven.be">Kris.Verlaenen@cs.kuleuven.be</a>&gt;<br>
To: Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>Date: Sun,  8 Mar 2009 03:56:29 +0100<br>Subject: Re: [rules-users] Drools Flow, constraint parametrization<br>Ricardo,<br>

<br>
If you need to access process variables and have only simple constraint<br>
expressions, I suggest you use code constraints (Java or MVEL dialect),<br>
as they have direct access to variables (and globals).<br>
<br>
If you want to use rule constraints anyway (because your constraints can<br>
become rather complex), there are a few options:<br>
<br>
 - You cannot use globals to pass information used in your constraints,<br>
because globals are considered immutable with respect to rule conditions<br>
<br>
 - You can put your data you want to access in your working memory.<br>
Rule constraints can then access this info just like any normal rule.<br>
<br>
 - You access the variable value using the special &quot;processInstance&quot;<br>
rule constraint (I just added a new section in the documentation to<br>
explain):<br>
<br>
Rule constraints do not have direct access to variables defined inside<br>
the process. It is however possible to refer to the current process<br>
instance inside a rule constraint, by adding the process instance to the<br>
working memory and matching to the process instance inside your rule<br>
constraint. We have added special logic to make sure that a variable<br>
&quot;processInstance&quot; of type WorkflowProcessInstance will only match to the<br>
current process instance and not to other process instances in the<br>
working memory. Note that you are however responsible yourself to insert<br>
(and possibly update) the process instance into the session (for example<br>
using Java code or an (on-entry or on-exit or explicit) action in your<br>
process). The following exampleof a rule constraint will search for a<br>
person with the same name as the value stored in the variable &quot;name&quot; of<br>
the process:<br>
<br>
processInstance: WorkflowProcessInstance()<br>
Person( name == ( processInstance.getVariable(&quot;name&quot;) ) )<br>
# add more constraints here ...<br>
<br>
Kris<br>
<br>
Quoting Ricardo Gil Alcaņiz &lt;<a href="mailto:rgil@okode.com">rgil@okode.com</a>&gt;:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; I&#39;m not a new drools user but I started to test rule flows (5.0M5)<br>
&gt; recently<br>
&gt; and I&#39;m stucked, so any clue will be welcomed :). I&#39;m testing how to<br>
&gt; share a<br>
&gt; StatefulKnowledgeSession between N rule flow instances. I&#39;m trying<br>
&gt; to<br>
&gt; parametrize each instance with process variables at start time but I<br>
&gt; don&#39;t<br>
&gt; know how to use them from rule constraints (in event waits, splits,<br>
&gt; etc.).<br>
&gt; I&#39;ve read the documentation and I&#39;ve found this text related to<br>
&gt; constraints<br>
&gt; &quot;Both rule and code constraints have access to globals that are<br>
&gt; defined for<br>
&gt; the process and can reuse imports at the process level.&quot; I tried it<br>
&gt; assigning (from an action) a variable value to a global variable but<br>
&gt; it&#39;s<br>
&gt; not working for me. ŋI&#39;m missing something?<br>
&gt;<br>
&gt; Thanks in advance!<br>
&gt;<br>
&gt; Ricardo.<br>
&gt;<br></blockquote></div><br>