Rafael Matos Rafael Matos - 2 years ago 165
Java Question

BPMN process variable

I'm using JPBM to design a process flow, with BPMN2. I want to instantiate a class object in a Script Task, for example:

Map<String, Object> params = new HashMap<String, Object>();
Person p = new Person("moi");
params.put("person", p);
ksession.startProcess("com.sample.bpmn.hello", params);

When I go into BPMN and create the process variable, so I can access it inside the script task, I get the following error: "Person cannot be resolved to a type"

How can I access that object through BPMN then? Thanks in advance

Answer Source

Figured it out. When creating the process variable, you have to define it as Object and provide the package path in Class Name. Instead of just creating an object, for example, of type Person, I had to actually type com.sample.Person, where com.sample is the package name. All variable reading and altering (get and set methods) is done with kcontext.getVariable("var") and kcontext.setVariable("var", newValue).

Hope this helps anyone :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download