Tips & tricks - Groovy conditions in the process

In the "Processes" module, conditions can be controlled with Groovy and thus also react to request values, among other things. In the example application, which you can download here from Intrexx version 12.0.0 and import as usual with the included process, a release should be triggered by clicking on a button and the data record should be saved. Another button, the "Cancel release" button, removes the release and also saves the data record.

The included process is deactivated during import. To test the sample application, activate the process after the import.

In the example application, the "Release" button is configured with the "Save" action and the "rq_action" parameter. "rq_action" is given the static value "release".

The "Cancel release" button is also configured with the "Save" action and the "rq_action" parameter. rq_action is given the static value "notReleased".

In the process, the data group event handler reacts to the insertion or modification of the data set.

The request parameter "rq_action" is read out with Groovy script, which is entered in the properties dialog of the Groovy condition in the editor:

            
if (g_request.containsKey('rq_action'))
{
	def l_strAction = g_request.get('rq_action')
	switch(l_strAction)
	{
		case "release":
		return [releasePressed]
		case "notReleased":
		return [releaseNotPressed]
	}
}

        

If the request parameter contains the value "release", the connection ID "releasePressed" is generated with the return statement. If the value is "notReleased", the connection ID "releaseNotPressed" is generated.

The connection ID is entered in the properties dialog of the respective branch. The name for a connection ID is freely definable but must always start with a lower-case letter.

In the following process step, the release status is set or canceled with a data group action. A user-defined, static Boolean value is used for this, which has the value "true" or "false" depending on the branch and is assigned to the "Release" data field.

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.