How to read element variable from multi-instance sub-process?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2014 10:14 AM
Hallo:
How to read element variable from multi-instance sub-process? For example, I add a collection of 3 elements to the sub-process and start the process. I wish to get corresponding the element variable for each of the 3 sub-process instances in order to get a mapping between element and sub-process instance.
I could read element variable from tasks(usertask, servicetask).
Thanks in advance!
How to read element variable from multi-instance sub-process? For example, I add a collection of 3 elements to the sub-process and start the process. I wish to get corresponding the element variable for each of the 3 sub-process instances in order to get a mapping between element and sub-process instance.
I could read element variable from tasks(usertask, servicetask).
Thanks in advance!
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2014 03:02 AM
Hi,
Variable should be accessible in the subprocess. (elementVariable :http://www.activiti.org/userguide/#bpmnMultiInstance)
If not please create jUnit test for it.
Regards
Martin
Variable should be accessible in the subprocess. (elementVariable :http://www.activiti.org/userguide/#bpmnMultiInstance)
If not please create jUnit test for it.
Regards
Martin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2014 05:04 AM
Hi Martin,
Thanks for the reply!
The bpmn file is attached and the unit test is as below. I assign a collection of 3 variable to the multi-instance sub-process and assert the 3 sub-process instances are running correctly. Then I wish to get element variable with predefined variable name for each of the sub-process instance using activitiRule.getRuntimeService().getVariable(), but it returns null.
I could get instance variable for multi-instance usertask/task using this way.
Thanks for the reply!
The bpmn file is attached and the unit test is as below. I assign a collection of 3 variable to the multi-instance sub-process and assert the 3 sub-process instances are running correctly. Then I wish to get element variable with predefined variable name for each of the sub-process instance using activitiRule.getRuntimeService().getVariable(), but it returns null.
I could get instance variable for multi-instance usertask/task using this way.
@Deployment(resources = { ExecuteMultiinstanceSubprocess.bpmn" })
public void test_ExecuteMultiSubprocess_should_acess_instance_elementvariable()
{
Map<String, Object> variables = new HashMap<String, Object>();
List<String> collectionVariables = new ArrayList<String>();
collectionVariables.add("elementVariable1");
collectionVariables.add("elementVariable2");
collectionVariables.add("elementVariable3");
variables.put("collectionVariables", collectionVariables);
ProcessInstance process = activitiRule.getRuntimeService().startProcessInstanceByKey("processAcsessSubprocessMultiinstanceVariable", variables);
List<Execution> subProccesInstances = activitiRule
.getRuntimeService()
.createExecutionQuery()
.activityId("subprocessMultiinstance")
.processInstanceId(process.getProcessInstanceId())
.list();
Assertions.assertThat(subProccesInstances.size()).as("number of parallel sub-processes instances").isEqualTo(3);
String elementVariable1 = (String) activitiRule.getRuntimeService().getVariable(subProccesInstances.get(0).getId(), "elementVariable");
Assertions.assertThat(elementVariable1).as("elementVariable should be elementVariable1 but get null").isEqualTo("elementVariable1");
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2014 03:49 AM
Hi,
You are right. 🙂
I checked that variables are in the DB, but they are not returned from the query. (jUnit test https://github.com/martin-grofcik/activiti-unit-test-template/tree/forum-element-variable)
Could you create issue for that?
Regards
Martin
You are right. 🙂
I checked that variables are in the DB, but they are not returned from the query. (jUnit test https://github.com/martin-grofcik/activiti-unit-test-template/tree/forum-element-variable)
Could you create issue for that?
Regards
Martin
