Access process info from spring bean invoked in the condition expression

114 views
Skip to first unread message

eaenes...@gmail.com

unread,
Dec 29, 2015, 5:09:41 PM12/29/15
to camunda BPM users
We are able to call spring bean methods in the condition expressions.

<sequenceFlow>
<conditionExpression xsi:type="tFormalExpression">
${beanClass.beanMethod() == 'foo'}
</conditionExpression>
</sequenceFlow>


Can we access current process info(processInstanceId, processDefinitionId, etc...) in the bean method; just like we can in the service tasks with the DelegateExecution class.

Ingo Richtsmeier

unread,
Dec 30, 2015, 4:14:06 AM12/30/15
to camunda BPM users, eaenes...@gmail.com
Hi,

just add the execution as a parameter to your method:

${beanClass.beanMethod(execution)}

From the DelegateExecution you have access to the process context. 

Kind Regards,

Ingo

eaenes...@gmail.com

unread,
Dec 30, 2015, 5:30:12 AM12/30/15
to camunda BPM users, eaenes...@gmail.com
30 Aralık 2015 Çarşamba 11:14:06 UTC+2 tarihinde Ingo Richtsmeier yazdı:
Thanks Ingo.
I also wanted to know if there is a way to get the user who completed the previous task of the sequence flow?

Ingo Richtsmeier

unread,
Dec 30, 2015, 6:43:43 AM12/30/15
to camunda BPM users, eaenes...@gmail.com

Philipp Ossler

unread,
Jan 4, 2016, 2:58:20 AM1/4/16
to camunda BPM users
Hi,

there are different ways to resolve the user who completed the previous task:

* using a process variable: use a task listener [1] and set the name of the user in a process variable which can be used later
* using the history: use the history service to query for the previous task

If you have a simple process (e.g. no parallel gateway) then you can find the previous task by ordering on the completion time. 

HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(execution.getProcessInstanceId()).orderByHistoricTaskInstanceEndTime().desc().singleResult();
String assignee = task.getAssignee();

Otherwise, you may use the model API to find the previous task first. Then you can use the activity id of the task instead of the ordering.

Greetings,
Philipp

Reply all
Reply to author
Forward
0 new messages