1 Reply Latest reply on Dec 12, 2011 6:35 AM by calca

    How to read external parameters from within a process?

    umarm

      Here's my code that starts a process:

      StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();  
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("doctorsDecision", "L1"); ksession.startProcess("MyProcess", params);

      And here's how I expect this variable to be available in MyProcess. This is the Action of one of my script tasks in MyProcess:

      System.out.println("doctorsDecision: "+doctorsDecision); 

      Is this the right way to access external variables from within a process?

       

      P.S.

       

      When I run my application, the process definition is never added to knowledge base because jBPM doesn't seem to recognize doctorsDecision variable. How can I tell jBPM that this variable is external and it's value will be provided on runtime? I am using BPMN2 files.

        • 1. Re: How to read external parameters from within a process?
          calca

          Hi Umar,

           

          You should declare the variable in your process

          In your bpmn file will look like this:

          <itemDefinition id="_doctorsDecisionItem" structureRef="String" />

          ...

          <process...>

             <property id="doctorsDecision" itemSubjectRef="_cvItem"/>

           

          No matter if it is "external" or not.

           

          In your script node you can use

          System.out.println(kcontext.getVariable("doctorsDecision"));

           

          Demian