Setting a Process Variable value in a Groovy Inline script

I have the following process:


What I would like tho achieve is that I can assign the value of a variable that is being set in the groovy script to an Output variable that is evaluated in the gateway.

Here’s the code:

def pmdCommand = '/usr/local/bin/python3.7 /users/harmprins/Documents/DEXRS/DEXDNBNew/software/ -t '+ Regulation + ' -f '+Frequency+ ' -d '+ ReportingDate.format('yyyy-MM-dd')

def sout = new StringBuffer()
def serr = new StringBuffer()

def process = pmdCommand.execute()
process.consumeProcessOutput(sout, serr)
loadReturnValue = process.exitValue()

So loadReturnValue is the value I want to evaluate like this:

${loadReturnValue == ‘1’}

But I get the following error message:

An error happend while submitting the task form :
Cannot submit task form 250c2da0-cfe7-11e8-b724-0a0027000000: ENGINE-02004 No outgoing sequence flow for the element with id 'ExclusiveGateway_0iepttu' could be selected for continuing the process.
So it seems the value is not set. How can I achieve setting the value of a process flow variable in a groovy Inline script?


There are two ways to set a process variable. You can use

execution.setVariable("loadReturnValue", process.exitValue())

or, keep your code as is, but make sure in your BPMN model that you have defined the return variable name for the script task…



1 Like

Thanks, that did the trick. What I did wrong was that I set the value using setVariable AND defined an output variable with the same name. Deleting the outputvariable solved the problem.