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 Taskit is observed that the process variables are not getting accessible, sinceWorkflowProcessInstanceobject is not available while rules are trying to fire. How to fix this issue? - How to access
Process Variablesthrough rules written inDRLorDecision Tables?
Resolution
- In order to fire the rules to update the process variables from
Rule Task, please ensure to insertWorkflowProcessInstanceobject intoKnowledge Runtime[1] before the rule node is fired. One way to do this is to add aScript Tasknode that executes the following:
kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());
- The attached test case
AccessProcessVariableInRule.zipis a simple demonstration which has been used around the newKIEAPI ofjBPM6to execute aBPMN2process definition to prove that the above functionality to access and updateProcess Variablefrom within a rule works. Users fromBRMS 5.3.xcan take the help of the same process definition attached in the test case for reference purposes as it should work with the oldKnowledgeBaseAPI too.
Root Cause
- Please ensure to insert
WorkflowProcessInstanceobject intoKnowledge Runtimebefore 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.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
