Advanced Techniques - Groovy conditions in a process
In the
Processes
module, conditions can be defined in Groovy which can be used to respond
to, among others, request values. In the example application, which you can
download
here and
import into your portal
with the included process as usual, the release process should be triggered
when a button is clicked on. The button saves the current data record at the
same time. To only save the current state, the Save
button can be used. When the user clicks on the "Release"
button, it also transfers the parameter
"rq_customMyParam" with the value "release".
In the process, a Groovy condition should be used to react to this parameter.
The Data group event handler responds to the adding or modifying (Record events:
"Insert" and "Change") of a
data record.
Using Groovy script, the request parameter defined in the
"Release" button is read in the condition. Here is the code example:
def strReleased = g_request.get('rq_customMyParam')
if("release" == strReleased)
return releasePressed
return releaseNotPressed
If the request parameter contains the value "release",
the connection ID "releasePressed" will be generated
using the return command. Otherwise the connection ID
"releaseNotPressed" will be generated.
The connection ID is entered in the
properties dialog of the respective branch.
The branch "releasePressed" is followed when the release
has been given. The branch "releaseNotPressed"
corresponds to the classic ELSE branch and is performed when the
Save button is clicked on - a request parameter
is not transferred in this case. The label for a connection ID can be chosen
freely but has to start with a small letter, as in our label example
"releasePressed".
In the subsequent process step, a Data group action is used to set the released status.
 |
All of the connection IDs defined in the Groovy condition must
be included in the process as outcomes of the condition, otherwise
this can lead to an error in the process execution.
|