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
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?
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.
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?
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!
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.