0 Replies Latest reply on Dec 13, 2011 5:55 PM by cross.cy

    Problem of getting WorkflowProcessInstance in Guvnor

    cross.cy

      Hi,

      I have a question about getting the current WorkflowProcessInstance in Guvnor business rule editor.

       

      In my test workflow, I have a script node before a rule task node, doing

      "kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance())" to insert the current process instance into working memory. In the rule task node, I'm trying to refer to a business rule defined using Guvnor. To use WorkflowProcessInstance in "When", I manually imported org.drools.runtime.process.WorkflowProcessInstance into the package. However, when i tried to call setVariable() method on the process instance, it always threw out null pointer exception at runtime. It looks like the business rule didn't pick up the WorkflowProcessInstance inserted by the previous script task. The source of the business rule is like:

       

      rule "Rejected App"

          ruleflow-group "rejection"

          when

            ......

              processInstance: WorkflowProcessInstance()

          then

             processInstance.setVariable("delay", 2);

             retract(processInstance);

      end

       

       

      I ended up using Eclipse to write a drl rule and uploaded to Guvnor to build the package, and it worked. My rule is like:

       

      rule "Rejected App"

          ruleflow-group "rejection"

          when

            ......

              processInstance: WorkflowProcessInstance()

          then

                          ((WorkflowProcessInstance)kcontext.getKnowledgeRuntime().getProcessInstance(processInstance.getId())).setVariable("delay", 2);

                          retract(processInstance);

      end

       

      Any suggestion on how to pick up the right WorkflowProcessInstance using Guvnor Bunisess rule editor? I'm using jBPM5.1 and Guvnor 5.2.Final. Thanks!

       

      Best regards

       

      Yu