cancel
Showing results for 
Search instead for 
Did you mean: 

Expressions, variables and processId

imamchishty
Champ in-the-making
Champ in-the-making
I have a spring bean which requires several variables, lets imagine the service method is as follows:

void doSomething(String song, String id);

The task is defined as below:

<serviceTask id="task1" name="songTask" activiti:expression="#{bean.doSomething(song, id)}>
<extensionElements>
<activiti:field name="song" stringValue="november rain" />
</extensionElements>
</serviceTask>

Questions:
1. When the task is fired song is not found, even though its been defined in the extension elements. I would've expected the song property to have been added to the variables map within the process instance.

2. The second param required is the actual process instance Id. I know that this can be obtained from the delegate expression, but I don't wish to make my beans have a dependency on activiti. How can the id passed in?

Thanks
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

1. That's right, you can only use process variables here that are already available in the process context. In your example song isn't available in the process context.
2. What you could do is use execution.processInstanceId as input parameter I think.

Best regards,

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Most being IN the process context means PERSISTED from what I see. If you have a task that is completed, but not committed (due to having a separate but needed transaction context) you cannot resolve variables in a subsequent servicetask. We ran into this problem to. I think that not yet committed variables should be in the threadlocal or something so they CAN be retrieved….

But this is just my experience lately (never ran into it because tasks were always committed… before continueing)

imamchishty
Champ in-the-making
Champ in-the-making
Thanks guys. I guess it makes sense that it failed. What got me was the implied nature of extensionElements.