Search code examples
javajbpm

Set process variable in JBPM 6


We are using JBPM 6.x and wanted to update process variables once process is in progress.

I have many example to access process variables in java code but nowhere clearly find how to set it in java code?

Just to give more background: We can set variables in process definition as

kcontext.setVariable();

How can we set in java code using API? OR how can get kContext? PLEASE HELP


Solution

  • Try with below approach:

     ProcessInstance processInstance= ksession.startProcess("com.sample.bpmn.hello",params);  
        RuleFlowProcessInstance ruleFlowProcessInstance= (RuleFlowProcessInstance) processInstance;
        ruleFlowProcessInstance.setVariable("processVar1","newValue");