This chapter discusses the following:
A workflow can contain several time triggers.
Figure 56: ConSol CM Process Designer - Time trigger
A time trigger is a mechanism which reacts when a certain period of time has elapsed. This can be required, for example, in the following situations:
Those use cases can be implemented using time triggers.
A time trigger can be configured to use a business calendar, i.e. to take only those times into consideration which are defined as working hours.
A time trigger can be attached to ...
A time trigger has to be of one of two types:
You, as a workflow developer, have to implement everything that should happen as a consequence when a time trigger has fired! There are no automatic actions. All the time trigger does, is to give a signal time elapsed - just like an alarm clock.
Grab the time trigger icon in the palette and drop it into the desired scope. It is automatically attached to the top of the scope. You can modify the position afterwards (move it to the left or right to change the order of triggers or just to improve the layout).
A time trigger, which has been attached to a scope, cannot be moved to another scope or activity. In case you would like to attach a time trigger to another scope/activity, remove the one you have defined and create a new one for the correct scope/activity.
To configure the properties of the trigger, select it in the editing panel and set the correct values in the Properties Editor. See section Properties of a Time Trigger.
You can draw connections from the trigger to put activities or decision nodes behind it. The first step which is executed after a time trigger always has to be an automatic activity!
Grab the time trigger icon in the palette and drop it into the desired activity. It will be attached to the corner of the activity.
A time trigger which has been attached to an activity cannot be moved to another scope or activity. In case you would like to attach a time trigger to another scope/activity, remove the one you have defined and create a new one for the correct scope/activity.
To configure the properties of the trigger, select it in the editing panel and set the correct values in the Properties Editor. See section Properties of a Time Trigger.
You can draw connections from the trigger to put activities or decision nodes behind it. The first step which is executed after a time trigger always has to be an automatic activity!
A time trigger has the following properties:
use calendar
Optional. Mark this check box when the business calendar should be taken into consideration when the time interval is calculated.
Please keep in mind that there are three steps which are necessary to make sure time intervals are calculated using a business calendar:
Principle of the use of a business calendar:
1 day means 24 hrs of absolute time, it has nothing to do with the use of a calendar. The calendar only plays a role when the time trigger is activated, then the 24 hrs, i.e. 86400000 milliseconds, will be taken as business calendar input (if the calendar is enabled).
Example:
When we have as trigger time 1 day = 24 hrs without calendar, the 24 hrs are calculated like regular time, so the escalation will fire one day later at the same time.
In contrast: When we use a calendar (with, for example, 7 work hrs per work day), the 24 hrs will be split-up according to the calendar, resulting in the firing event more than 3 days later (24 hrs = 3 x 7 hrs + 3 hrs).
See also section Working with Calendars and Times.
The script on timer start is executed again. The first firing event is initialized by the (technical) user admin, all following firing events are initiated by the Job Executor.
Figure 57: ConSol CM Process Designer - Properties of a time trigger
The time measuring of a trigger is started (i.e. the trigger is initialized) when the ticket enters the scope/activity. It stops (i.e. the trigger fires) when the defined period of time which has been set as fixed value (minutes/hours/days) or the manually defined time has elapsed.
When you, as a workflow developer, would like to initialize a trigger using other values, this has to be done using scripts. Here, short examples will be provided, please see section Working with Calendars and Times for a detailed explanation of programming workflow trigger times. In those chapters, the code examples are provided, too.
A time trigger can also be deactivated. In Example 2, this would be required to prevent the time trigger from firing initially, because it should not be initialized before any e-mail comes in.
The implementations for the use cases mentioned above (see Introduction to Time Triggers) would be:
Figure 58: ConSol CM Process Designer - Use case 1: Workflow
Figure 59: ConSol CM Process Designer - Use case 1: Properties Editor for time trigger
Figure 60: ConSol CM Web Client - Use case 1: Date picker
Figure 61: ConSol CM Process Designer - Use case 2: Workflow
Figure 62: ConSol CM Process Designer - Use case 2: Properties Editor for time trigger
Figure 63: ConSol CM Web Client - Use case 2: Ticket list
Figure 64: CM Process Designer - Use case 3: Workflow
Figure 65: ConSol CM Process Designer - Use case 3: Properties Editor for time trigger
Figure 66: ConSol CM Web Client - Closed ticket
The following methods are of major importance when you work with time triggers.
The most important object in a script of a trigger is the trigger itself. It is an object of the Java class TimerTrigger and it is implicitly available as trigger in each trigger script.
workflowApi (the singleton instance of the WorkflowContextService) offers two methods to reinitialize the firing time of a trigger. Reinitialization means the trigger is reset to its original state with no time elapsed. In both methods, the trigger name (pTriggerName) has to be provided as path, explanation see section about working with path information.
reinitializeTrigger(String pTriggerName)
The trigger is reinitialized with the base date of the ticket entering the respective scope.
Please see also section Working with Calendars and Times.
This script could be used as a script on timer start for a time trigger at a scope. It will initialize the trigger for an escalation depending on the queue, i.e. if the ticket is in the HelpDesk_1st_Level queue there is less time until the escalation than in the HelpDesk_2nd_Level queue.
Within the scripts scripts on timer start and script after timer, the object triggerexists as an implicit initialization of TimerTrigger. So you can work using triggers without any steps before. However, in an Admin Tool script you will have to import the TimerTrigger class or the respective Java package.
The following script could be used in a service desk and help desk environment and placed in the following TimerTrigger.
Figure 67: ConSol CM Process Designer - TimerTrigger in ServiceDesk workflow
def addedEscalMillis = 0
switch (ticket.queue.name) {
case "HelpDesk_1st_Level":
addedEscalMillis = 12*60*60*1000L;
break;
case "HelpDesk_2nd_Level":
addedEscalMillis = 24*60*60*1000L;
break;
case "ServiceDesk":
addedEscalMillis = 4*60*60*1000L;
}
trigger.setDueTime(addedEscalMillis)
Code example 7: Example for a script on timer start
For this example, it makes sense to use fixed values for the times directly in the script code. In real life environments you might want to store escalation times and the like in system properties and retrieve them using the configurationService. That way, an administrator can easily access and edit the escalation times without any manipulation of the workflow implementation.
In real life, a business calendar might also be used - please see Example 2.
In the server.log file, you can see the time when the trigger is supposed to fire.
Figure 68: File server.log with calculated time trigger DueTime
The same principle could be applied to calculate the escalation time depending on the ticket priority, the VIP status of a customer, or any other parameter.
def now = new Date()
def wunschTermin = ticket.get("helpdesk_standard", "date_test")
def twoWorkDays = -2*8*60*60*1000L
// calculate escalation date
def escalDate = BusinessCalendarUtil.getEscalationTime(wunschTermin, twoWorkDays, ticket.queue.calendar)
// calculate and set due time
trigger.setDueTime(escalDate.time - now.time)
Code example 8: Calculate and set time for TimerTrigger using BusinessCalendar (valid for CM versions 6.10.6 and up)