Muthukannan Kanniappan
Muthukannan Kanniappan

Reputation: 2079

How to access the process params in a Rule Task?

Am using JBPM5, I have modeled a process, which onStart goes to a RuleTask.

Map<String, Object> params = new HashMap<String, Object>();
params.put("citizenName", "Nannak");
params.put("citizenAge", 23);
ksession.startProcess("com.sample.medicalcheckup", params);

How to access the 'citizenAge' in the Rules 'when' segment?

Thanks in Advance!

Upvotes: 0

Views: 2474

Answers (2)

zhy2002
zhy2002

Reputation: 389

In drools 6 you can use this:

drools.getContext(org.kie.api.runtime.process.ProcessContext.class).getVariable("processParam1")

Upvotes: 0

Muthukannan Kanniappan
Muthukannan Kanniappan

Reputation: 2079

Had to add a script task before the rule task which fetches the process params and insert to the knowledgeContext.

org.drools.runtime.process.WorkflowProcessInstance process = org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();
System.out.println(process.getVariable("citizen"));
kcontext.getKnowledgeRuntime().insert(process);         

Hope I can do the same before start the process too..

Thanks to examples provided here

Upvotes: 1

Related Questions