Tips & Tricks - Starting Processes
This post shows different ways to start processes—including using Groovy to pass parameters at the same time. To access all the settings mentioned, please enable "Expert Options " in the corresponding modules.
Starting Timers Using Groovy and Passing Parameters
Timers in processes can be started using Groovy. Parameters can also be passed to it. You can download our sample process here and import it as usual. The figure below shows the process opened in the "Processes" module.
Process Structure
1. Generic event handler with or without parameters
In the Properties dialog for these two generic event handlers, you'll see that the class "de.uplanet.lucy.server.workflow.eventhandler.UserWorkflowEventHandler" is selected. The eventGuid is automatically assigned when this class is selected and entered as a property. With this configuration, the timer (3) included in the process can be started. You'll learn how to do this after reading the description of the process elements.
2. Groovy action with or without parameters
The two Groovy actions contain scripts that start the timer either with or without passing parameters at the same time. This function returns the "JobStarter" class. The script for the Groovy action "With Parameters" looks like this:
import de.uplanet.lucy.server.scheduler.JobStarter
JobStarter.startJob("<Timer-GUID>", [testParam: true, greeting: ' Hello world!'])
The parameters "testParam" and "greeting" are available in SharedState once the process has started.
Here is the script for the Groovy action "No Parameters":
import de.uplanet.lucy.server.scheduler.JobStarter
JobStarter.startJob("<Timer-GUID>")
Replace <Timer-GUID> in the script with the current GUID of the timer you want to start. In our example process, it is the timer GUID "B39F3AA1C06E56FD06538F92F46C075333F97F68".
3. Timer
This timer should be started.
4. Timer Event Handler
The timer event handler is linked to the timer and is triggered when the timer starts.
3. Groovy Condition
The Groovy condition checks whether there are any parameters. It contains the following script:
println(g_sharedState)
return g_sharedState.testParam ? with_params : without_params
In the first line, the sharedState is written to the process log file.
Depending on the result, the second line branches to the corresponding Groovy action that follows.
4. With parameters / 5. Without parameters
The Groovy actions write the respective result to the process log file.
println("With parameters.")
println(g_sharedState.greeting)
println("Without parameters.")
println(g_sharedState)
Start the process
1. Activate the process
If the process is still disabled, enable it by clicking in the upper-left corner (1).
2. Trigger an event
You can now start the process using the "Trigger This Event Now" context menu option in the Generic Event Handler.
You will then find the result in the process log file.
Start a Process via a Task
To execute a process as a follow-up task, a generic event handler is required within the process. In the Generic Event Handler Properties dialog, select the class "de.uplanet.lucy.server.workflow.eventhandler.UserWorkflowEventHandler" on the "Generic Event Handler" tab. The "eventGuid" parameter, which is automatically generated during this process, has a GUID as its value. Copy this GUID to the clipboard or save it elsewhere (e.g., in a text editor) for later use. Additional process elements can now be connected to the generic event handler as usual.
When using a generic event handler, no data group reference is established. Consequently, dynamic data sets, for example, are not available.
Using the GUID defined in the generic event handler, the process can now be started from the task scheduler, which you can find in the "Tools" module.
To do this, select any task from the list. You can access the "Follow-up Orders" tab via the "Edit Schedule" context menu. There, you can enter the eventGUID of the generic event handler in the "Process Event GUID" field. The process will start as soon as the task is completed.
Start the process via data transfer
In the "Integration" module, processes can be initiated following a data transfer. To do this, open the Properties dialog box for an existing data transfer and go to the "Follow-up Jobs" tab. There, you can enter the eventGUID of the generic event handler in the "Process Event GUID" field. The process will start as soon as the data transfer and its follow-up tasks have been completed.
Start a process using JavaScript
A process can also be started using JavaScript as follows:
function prozess_start()
{
triggerUserWorkflowEvent("GUID");
}
The triggerUserWorkflowEvent() function starts the process. The eventGuid of the corresponding generic event handler must be passed to this function.
You can determine the GUID by pressing the F4 key when the generic event handler is selected in the process.







