Unable to access process variables through rules in Rule Task while using WorkflowProcessInstance
Environment
- Red Hat JBoss BRMS (BRMS)
- 5.3.x
- Red Hat JBoss BPM Suite (BPMS)
- 6.0.x
Issue
- While trying to update process variables through rules in
Rule Task
it is observed that the process variables are not getting accessible, sinceWorkflowProcessInstance
object is not available while rules are trying to fire. How to fix this issue? - How to access
Process Variables
through rules written inDRL
orDecision Tables
?
Resolution
- In order to fire the rules to update the process variables from
Rule Task
, please ensure to insertWorkflowProcessInstance
object intoKnowledge Runtime
[1] before the rule node is fired. One way to do this is to add aScript Task
node that executes the following:
kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());
- The attached test case
AccessProcessVariableInRule.zip
is a simple demonstration which has been used around the newKIE
API ofjBPM6
to execute aBPMN2
process definition to prove that the above functionality to access and updateProcess Variable
from within a rule works. Users fromBRMS 5.3.x
can take the help of the same process definition attached in the test case for reference purposes as it should work with the oldKnowledgeBase
API too.
Root Cause
- Please ensure to insert
WorkflowProcessInstance
object intoKnowledge Runtime
before the rule node is fired.
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments