12-26-2020 07:36 AM
I'm using `activiti-spring-boot-starter:7.1.0.M6`.
As I read [document][1], to pass process varibles to sub-process, I need to use
<!-- Main Process -->
<bpmn:callActivity id="mainActivity" name="TASK_NAME" calledElement="subProcess">
<bpmn:extensionElements>
<activiti:in target="subVarName" source="mainVarName"/>
<activitiut target="mainVarName2" source="subVarName2"/>
</bpmn:extensionElements>
<bpmn:incoming>flow1</bpmn:incoming>
<bpmnutgoing>flow2</bpmnutgoing>
</bpmn:callActivity>
After I passed the variable, I thought it would be OK that process call `subVarName` in bpmn, but it wasn't.
I got `UnknownPropertyException` when engine referred `subVareName`.
<!-- Sub Process -->
<bpmn:serviceTask id="subActivity" name="SUB_TASK_NAME"
activiti:expression="${mySpringService.method(subVarName, execution)}">
<bpmn:incoming>subFlow1</bpmn:incoming>
<bpmnutgoing>subFlow2</bpmnutgoing>
</bpmn:serviceTask>
I already checked that `mainVarName` is not null because it is used by prior service task in main process.
Please let me know what I missed... Thanks!
[1]: https://www.activiti.org/userguide/#bpmnCallActivityPassVariables
01-04-2021 02:12 AM
The guide you are referring to belongs to an older version. i don't see similar topic in Activiti7. can you please post this on the gitter channel?
01-05-2021 12:37 PM
I solved problem by using 'taskListener'.
And what I missed is that subprocess from 'callActivity' cannot receive variables. I saw that kind of description in this community.
By the way, is there any difference of 'DelegationExecution' between 'taskListener' and 'ExecutionListener'?
When I completed task with task parameters, the former can retrieve variables but it disappeared, the latter does contrary.
01-06-2021 01:52 AM
I believe task listener uses DelegateTask whereas execution listener uses DelegateExecution, so the tasklistener might have access to locally scoped task variables. could you please share some sample code for better clarity on behavior?
01-06-2021 04:07 AM
Sorry, I solved problem by setting variable scope.
But for giving information about this, I'll append sample code.
When I completed task like below,
taskService.complete(task.getId(), taskParam);
In my BPMN,
<bpmn:userTask id="myTask" name="My Task" activiti:assignee="assigneeProperty"> <bpmn:extensionElements> <activiti:taskListener expression="${mySpringService.methodToTrigger(execution)}" event="complete"/> </bpmn:extensionElements> <bpmn:incoming>incomingFlow</bpmn:incoming> <bpmn:outgoing>outGoingFlow</bpmn:outgoing> </bpmn:userTask>
In my service
@Service public class MySpringService {
public void methodToTrigger(DelegateExecution execution) {
// In task listener, I can get value
// But in execution listener, I cannot get value but can set process variable.
// In both cases, getVariableLocal always returns null. Object object = execution.getVariable(variableKey); log.debug(object); } }
But I solved like below.
// Specify variable scope as local taskService.complete(task.getId(), taskParam, true);
@Service public class MySpringService { public void methodToTrigger(DelegateExecution execution) { // Get variable local Object object = execution.getVariableLocal(variableKey); log.debug(object); } }
Thank you for your help!
Explore our Alfresco products with the links below. Use labels to filter content by product module.