cancel
Showing results for 
Search instead for 
Did you mean: 

How to set field for Java Service Task to business key?

schmke
Champ in-the-making
Champ in-the-making
I have a Java Service Task that needs a value passed in that happens to be the business key for my process.  I know I could use execution.getProcessBusinessKey() to retrieve it but that would make the Java Service Task hardcoded to only work with processes where the value in question is the business key.  I'd prefer to pass the value in as a field expression.

However, it appears field expressions can only contain variable references?  If so, is there not a way to set a field to the value of the business key?

Yes, I could duplicate the value from the business key into a variable as well, but I'd rather not have to do that.

Is there a solution I'm missing or is what I want to do not possible?

Thanks.
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
In your service task, you could get the business key via execution.getProcessInstance().getBusinesskey() ?

schmke
Champ in-the-making
Champ in-the-making
Yes, but now my service task would be hard-coded to requiring the value to be the business key rather than being able to be more generic and have it set as a field.  I'd prefer the service task to be generic and not care how the process implementor chose to use variables or the business key so it is more reusable and not tightly coupled to a specific process.

For now, I've just gone ahead with having a process instance variable with the value so I can set the field for the service task.  This keeps the service task abstracted away from the details and the only cost is duplicating the value in both the business key and a variable.  Or perhaps I won't use the business key now.