Search code examples
jbpmbpmnkiekie-workbenchkie-wb

How to set Parameter in WorkItem to be reached within BPMN Process in jbpm-WorkBench


I have created a custom WorkItem with some parameters, which I have registered in WorkDefinitions.wid file. Then in Business Process I also create Variable Definitions for the entire Process and reference those from WD.wid of my custom WorkItem to those created in BP.

WorkItem execute the code, which takes those parameters from the form after starting the process. For this purpose I use getParameter()- method; It looks as follows:

public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

String payload = workItem.getParameter("id") + ... ;
...
manager.completeWorkItem(workItem.getId(), null);
}

Everything looks and works ok, cause WorkItem will be successfully executed and I get the result (on the server side after executing workItem in BP); But now I need to get Response after executing POST method with entered parameters. In the code I've created a new variable, which gets parameter from response body and I can see result in the IDE's console, when I execute pure code (without BPMN - process), but I need also register this variable within WorkItem to use it further for the next Task in my BProcess.

SO My Question is: is there something similar to getParameter() - method, but something as setParameter()? How could I register it within WorkItem and how could I get/reach those parameter/variable within BProcess in jbpm (something as global variable I believe).

Thank you very much!


Solution

  • Look at the Javadoc of WorkItemManager and see the parameters of completeWorkItem method. You can pass your results in a map. You will then get those values as output parameters of the task that is being executed and can map them to some process variables so the next task can use them.