# CMMN delegate - get field expression

**URL:** https://forum.flowable.org/t/cmmn-delegate-get-field-expression/5437
**Category:** Flowable Engine
**Created:** [February 13, 2020, 9:36am UTC](https://forum.flowable.org/t/cmmn-delegate-get-field-expression/5437 "2020-02-13T09:36:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![DavidPLamas](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@DavidPLamas](https://forum.flowable.org/u/DavidPLamas)
#### Post date: [February 13, 2020, 9:36am UTC](https://forum.flowable.org/t/cmmn-delegate-get-field-expression/5437/1 "2020-02-13T09:36:46Z")

</div>

Hi,

We have a custom expression manager that evaluates expressions defined in the bpmn process using ejb’s. As you may know, when you ask the container to give you a reference to the class, it returns a proxy of that class. We apply this behavior when resolving ServiceTasks, TaskListeners, ExecutionListeners and EventListers implementation at runtime.

Because our implementation returns a proxy of that class, Flowable cannot automatically inject expressions in the class since it cannot find the fields or setters using reflection.  
To resolve this issue, we use org.flowable.engine.delegate.DelegateHelper to fetch the field expression when the bean is actually being executed, like for example:

```xml
<process id="process" name="My process" isExecutable="true">
    <startEvent id="startNoneEvent1" flowable:initiator="initiator" flowable:formFieldValidation="false"/>
    <sequenceFlow id="sequenceFlow2" sourceRef="startNoneEvent1" targetRef="serviceTask1"/>
    <serviceTask id="serviceTask1" name="Service task" flowable:delegateExpression="${myServiceTaskBean}">
      <extensionElements>
        <flowable:field name="event">
          <flowable:string><![CDATA[CALL_SOMETHING]]></flowable:string>
        </flowable:field>
      </extensionElements>
    </serviceTask>
    <endEvent id="endNoneEvent2"/>
    <sequenceFlow id="sequenceFlow3" sourceRef="serviceTask1" targetRef="endNoneEvent2"/>
  </process>

```

```java
@Stateless(name = "myServiceTaskBean")
@TransactionManagement(TransactionManagementType.BEAN)
public class MyServiceTask implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        String event = (String) DelegateHelper.getFieldExpression(execution, "event").getValue(execution);
       // event = "CALL_SOMETHING";
    }
}

```

This works fine and hasn’t given us problems.

Now we’re starting to use CMMN and a new problem arises: how do we do we apply this type of behavior for the CMMN context, more specifically using org.flowable.cmmn.api.delegate.DelegatePlanItemInstance ? The DelegateHelper only has methods working with org.flowable.engine.delegate.DelegateExecution and org.flowable.task.service.delegate.DelegateTask.

Do you know if there is any other helper class to achive what we need?

---

<div class="post-metadata">

### Author: ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)
#### Post date: [February 19, 2020, 6:02pm UTC](https://forum.flowable.org/t/cmmn-delegate-get-field-expression/5437/2 "2020-02-19T18:02:21Z")

</div>

Well spotted. The CMMN counterpart for the DelegateHelper was indeed not added to the CMMN engine yet. It is now: [https://github.com/flowable/flowable-engine/commit/cc725d68fc29d297898838894a85a7a4ad2e0d32](https://github.com/flowable/flowable-engine/commit/cc725d68fc29d297898838894a85a7a4ad2e0d32)

You can copy the CmmnDelegateHelper class in your projects as-is (as they are static methods) and remove it with the next release.
