cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass an object field from a process to a sub-process

houstoniasian
Champ in-the-making
Champ in-the-making
In the main process, I have a list of employee {firstName, lastName}

to call multi sub-processes, the XML is as follow:


  <callActivity id="callActiviti" name="Call Sub Process" activiti:exclusive="false" calledElement="subProcess">
      <extensionElements>
        <activiti:in source="employee.firstName" target="firstName"></activiti:in>
        <activiti:in source="employee.lastName" target="lastName"></activiti:in>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="employeeList" activiti:elementVariable="employee">  </multiInstanceLoopCharacteristics>
    </callActivity>


I know the source "employee.firstName" has to be something else.  What should I put there?

Thank you,

Tan
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
You should use sourceExpression instead, e.g.:

<activiti:in sourceExpression="${employee.firstName}" target="firstName"></activiti:in>

houstoniasian
Champ in-the-making
Champ in-the-making
It does not work. 

First of all, how does activiti even know the definition of "employee" object?  I defined Employee with private firstName & private lastName.  Then I have the public employee.getFirstName() & employee.getLastName().  I also have a bean "employee" defined in "activiti-standalone-context.xml":   <bean id="employee" class="domain.Employee" />

I feel like either Activiti does not support passing object feature or I miss something.

Tan

frederikherema1
Star Contributor
Star Contributor
Not really sure what you're trying to do here. Most of the time, you use "employee" (or any arbitrary name) in expressions if you want to reference process-variables. All process-variables are exposed in the expressions. So if you have a POJO (serializable) instance of type com.mycompany.Employee set as "employee" variable, it's available in expressions.

If you then use "${employee.firstName}", JUEL (EL implementation) gets the employee-pojo and checks if there are getters for the "firstName" property. In case "employee" was instance of a Map, it whould try to get the value for key "firstName".

You can also reference beans from within your expressions. So if you have a bean configured in the configuration, it should be accessible to all of your expressions. Make sure it's configured correctly. If you're usine the SpringProcessEngineConfiguration, by default ALL spring-beans are exposed. If you're using the "normal" configuration, you should manually register what beans you want to see exposed (see userguide, beans-section)…