Groovy Console

   Journey Manager (JM) The transaction engine for the platform.  |    Form Builder Platform Developer |  17.10 This feature was introduced in 17.10. |  23.04This feature was updated in 23.04

Manager comes with the GroovyGroovy is a powerful scripting language which runs on the Java Virtual Machine. Across theTemenos Journey Manager platform, Groovy is used to create services in Manager. These services are primarily used to create plug-in style systems that interact with Manager. console enabling developers to rapidly develop and test Groovy scripts. Groovy console has access to all services and libraries, which allows you to simulate the behaviors of any Groovy service.

Note

You must have the Groovy Console permission set to your user account to run Groovy scripts in the Groovy console.

To run a script in the Groovy console:

  1. Select Services > Groovy Console.
  2. Select the Groovy Script tab to write or edit a Groovy script. You can write a part of a script or a simple function to be executed and tested.
  3. Select the Secure Fluent API Only checkbox to enforces the use of Transact Fluent API in this Groovy script. It is selected by default. Clear this checkbox if you want to test the Groovy script that uses Transact Core API.
  4. Note

    At installation time, the system wide build property groovy.secure.api defines whether the Secure Fluent API Only service parameter is editable or available.

  5. Select the Commit DB Changes checkbox to commit any changes, made by the Groovy script, to the database. Otherwise, the changes will be rolled back. This is handy when you want to test a Groovy script that writes to the database, but you don't want to delete these test records from the database manually. It is not selected by default.
  6. Enter a timeout in the Execution Timeout (sec) field to specify the Groovy script execution timeout in seconds, after which a timeout exception will be thrown. The default is 60 sec.
  7. Select the Generate Event checkbox to generate events for the changes, made by the Groovy script. It is not selected by default. You can see generated events in the Event Log as well as in the transaction time line of the respective submission.
    Note

    The events are created only when both the Commit DB Changes and the Generate Event checkboxes are selected and the changes, applied to the Manager's entities, satisfy criteria defined in the Event Configuration Storage Definition.

    Note

    The Generate Event checkbox is not shown if the eventing feature is disabled in deployment properties.

  8. Click Execute Script to run it. The script output or an error message is shown in the Execution Output window.
  9. Click Syntax Check to validate the Groovy script, which checks the script spelling, as shown below.
    
    [Static type checking] - Cannot find matching method Script1#printl(groovy.lang.GString). 
    	Please check if the declared type is correct and if the method exists.
    	@ line 2, column 1.
    	printl "Hello world, $it"
    	^
     
    	1 error
    
  10. Click Clear Output to clear the Execution Output text field.
  11. Click Clear Script to clear the Groovy Script text field.
  12. Click Save Script to save the script.
  13. Select the Service Parameters tab to create or edit existing Groovy script parameters.
    Manager Groovy console service parameters
  14. Click New to create a new parameter or click Edit to update an existing parameter.
  15. Edit a name and a value.
  16. Click Save to update the changes.

Now, you can use companyName parameter in the Groovy script, for example:


def name = serviceParameters.companyName
	(0..9).each {
		println "Hello $name, $it"
	}		

You can use more complex Groovy code snippets including imports, as shown below:


import com.avoka.tm.query.*
import com.avoka.tm.vo.*

String trackingCode = "LHC5DD"
String txnPropertyName = "Monty"

Txn txn = new TxnQuery()
	.setTrackingCode(trackingCode)
	.firstValue()

// PropertyQuery() to access the Monty property value
String txnPropertyValue = new PropertyQuery()
	.setName(txnPropertyName)
	.setTxn(txn)
	.getValue()

// expected result: txnPropertyValue = Python
println "txnPropertyValue = ${txnPropertyValue}"
Note

A script saved in the Groovy console is specific to each user, so when you open the console next time, you will see your recently accessed script in there.

Next, learn about Groovy service log.