Passing Task Variables to Process Variables

So I have a workflow that’s got a coupe pathways to take depending on what a user chooses to do. There’s a taskLocalVariable, called “action” that is set to either be approved or declined. If approved, I want the workflow to proceed to the next step. Declined moves the workflow to a prior step. I’m trying to transfer the “action” into a process variable so that I can use a conditional gateway to manage this behavior. The problem I’m having is that while I have a task listener set up, it’s proving hard to figure out how to do this.

This expression

${ execution.setVariable( ‘lastAdoAction’, ‘goober’ ) }

in the task listener works just fine. But if I try to actually get a hold of the “action” variable of the task, I’m not able to access it (comes back null). Reading around in the docs it sounds like this is a situation where I need a script task listener, but that’s not an option I can select using the eclipse designer. Do I need to go in and edit the BPMN file manually to get the task listener inserted, or do I really need to start writing the delegate task objects and attach them to the class path?

I’m not sure if I understand your question, but I’m gonna try to answer.

A example of decisions can be found in this excellent tutorial:

An example of a script executionListener. From the modeler you can download the xml and modify it in a text editor. Afterwards just import it again.

	<serviceTask id="GetReleaseVersions" name="GetReleaseVersions"
			<flowable:field name="requestMethod">
			<flowable:field name="requestUrl">
			<flowable:field name="saveRequestVariables">
			<flowable:field name="resultVariablePrefix">
			<flowable:executionListener event="end"
				<flowable:field name="script">
						responseBody = execution.getVariable("a"); 							
			            var b = a++

						execution.setVariable("b", b);

				<flowable:field name="language">

An example of using java code:

1 Like

Yeah, this is exactly the help I needed. Between the tutorial and the script example you included, I should be able to get off the ground and functional. Thanks.