AnsweredAssumed Answered

Cannot resolve identifier within the same activity

Question asked by rajivmoghe on Apr 19, 2016
Latest reply on Apr 26, 2016 by jbarrez
I have a process that goes as follows:

Start Process (initiator='someuser') –> Step 1 (performed by the initiator) –> Step 2 (performed by initiator's manager).
I use a userService to get the requisite values of performer, and account. The xml fragment is shown below:


    <dataObject id="initiator" name="initiator" itemSubjectRef="xsd:string">
      <extensionElements>
        <activiti:value>Filled from ReST Call</activiti:value>
      </extensionElements>
    </dataObject>

    <serviceTask id="service1" name="My Action 1" activiti:class="org.activiti.demo.MyServiceClass">
      <extensionElements>
        <activiti:field name="performer">
          <activiti:expression><![CDATA[${initiator}]]></activiti:expression>
        </activiti:field>
        <activiti:field name="suac">
          <activiti:expression><![CDATA[${userService.getAccountFor(performer, stream)}]]></activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>

    <sequenceFlow id="flow4" sourceRef="service1" targetRef="service2"></sequenceFlow>

    <serviceTask id="service2" name="My Action 2" activiti:class="org.activiti.demo.MyServiceClass">
      <extensionElements>
        <activiti:field name="performer">
          <activiti:expression><![CDATA[${userService.getManagerFor(initiator)}]]></activiti:expression>
        </activiti:field>
        <activiti:field name="suac">
          <activiti:expression><![CDATA[${userService.getAccountFor(performer, stream)}]]></activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>

The userService is defined as:

@Component
public class UserService {

    public String getManagerFor(String string){
       return string+"'s manager";
    }

   public int getSUAccountFor(String user, String stream) {
      System.out.println("Fetching default StreamUserAccount for "+user+" for "+stream);
      return 10;
   }
}

Question:
When invoked, the process fails in service1 with
org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'performer' 
.

What is the best way for me to pass potentially different performer for each invocation of the service task (The performer for service2 is the initiator's manager) and also get the performer-appropriate account token for the same invocation?

Outcomes