Close
Thank you for your feedback.

Timer workflow activity

Timer workflow activity

The Timer activity pauses the workflow for a specified period of time.

This duration can be an absolute time value or a relative value based on a defined schedule. It is best to adjust the Duration so the workflow can progress in a timely manner. To pause a workflow indefinitely until a condition is met, see wait for condition.

Results

Table 1. Timer activity results
ResultDescription
CompleteThe activity successfully reached the specified duration.
CancelledThe activity or workflow was canceled before the timer reached the specified duration.

Input variables

Input variables determine the initial behavior of the activity.

Table 2. Timer activity input variables
FieldDescription
Timer Information
Timer based onHow the timer duration is computed. The options are:
  • A user specified duration: The duration is based on the Duration fields, such as days and hours.
  • A relative duration: The duration is based on the Relative duration (such as End of Next Business Day) and Wait fields.
  • A date/time or duration field: The duration is based on the Field value and the Wait field.
  • Script: The duration is based on a script that returns the number of seconds.
Duration

Appears only when Timer based on is A user specified duration.

The specific number of days and hours to wait before proceeding to the next activity in the workflow.
Relative duration

Appears only when Timer based on is A relative duration

The general number and length of business days to wait before progressing to the next workflow activity. .
Wait

Appears only when Timer based on is A relative duration or A date/time or duration field.

An additional timer adjustment when Timer based on is A relative duration or A date/time or duration field. The options are:
  • The full duration: No modification of the calculated duration.
  • A % of the duration: The duration is adjusted by multiplying the number of seconds by the (Percentage / 100).
  • Some time before: The duration is shortened by the Time before days and hours.
  • Some time after: The duration is lengthened by the Time after days and hours.
Percentage

Appears only when Timer based on is A relative duration or A date/time or duration field.

The Wait percentage value when Timer based on is A relative duration or A date/time or duration field.
Time before

Appears only when Timer based on is A relative duration or A date/time or duration field and Wait is Some time before.

The modifier time value when Wait is Some time before.
Time after

Appears only when Timer based on is A relative duration or A date/time or duration field and Wait is Some time after.

The modifier time value when Wait is Some time after.
Field

Appears only when Timer based on is A date/time or duration field.

The date/time or duration field that contains the elapsed wait-time before moving to the next workflow activity.
Script

Appears only when Timer based on is Script

The script that sets 'answer' to the number of seconds for the duration.
Timer Schedule
Schedule based onThe basic schedule the timer uses to count working hours. If a schedule is specified, the duration will only be considered for times that are specified on the schedule. For example, if the duration is 2 hours and the workflow begins at 4:00pm on a schedule that is 8am - 5pm, then it ends at 9:00am the next day. The options are:
  • This workflow's schedule: The schedule uses workflow context date, time, and an optional Time zone based on value.
  • A specific schedule: The schedule uses a pre-defined Schedule and an optional Time zone based on value.
  • A schedule field: The schedule uses a value from a table and an optional Time zone based on value.
Schedule

Appears only when Schedule based on is A specific schedule.

The pre-defined Schedule from a list.
Schedule field

Appears only when Schedule based on is A schedule field.

A date and time or duration field for the schedule, that is associated with the table. Valid fields appear in blue on the Select the element from a tree dialog.
Timer Time Zone
Time zone based onThe time zone for calculating the duration. The time zone may be based on:
  • No time zone: Default. Workflow uses the GMT time zone.
  • A specific time zone: A predefined Time zone.
  • A time zone field: A Time zone field to track time duration from a field on the form.
Time zone

Appears only when Time zone based on is A specific time zone.

The predefined time zone.
Time zone field

Appears only when Time zone based on is A time zone field.

A date and time or duration field for the schedule, that is associated with the table. Valid fields appear in blue on the Select the element from a tree dialog.

States

The activity state tells the workflow engine what to do with the activity.

Table 3. Timer activity states
StateDescription
ExecutingThe Timer activity is in this state very briefly while initializing, after which it immediately changes to Waiting.
WaitingThe workflow engine waits until the timer reaches the specified duration. The engine then transitions the workflow to the next activity.
FinishedThe activity finished running. See the result value for the outcome of the activity.
CancelledThis activity, or the workflow that contains this activity, was canceled.
ErrorA JavaScript error occurred. Review the logs for error details.

Example

You can use a Timer activity to pause the workflow until the end of the business day.

Figure 1. Timer example

In this example, the script evaluates the time between the now variable and the eod variable. The eod variable is defined, in 24 hour time, as 4:00 PM. The script then sets the answer variable to the difference between these variables, in seconds, and logs a message.

// get now and calc end of day (4:00pm)
 
var now =new Date();
 
var eod =new Date();
eod.setHours(16);
eod.setMinutes(0);
eod.setSeconds(0);
 
answer =(eod.getTime()- now.getTime())/1000;
 
workflow.debug('Timer will fire @: '+ eod +'  '+(answer/60)+' minutes from now');

Products > ServiceNow Platform > Workflow; Versions > Helsinki