Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

WorkflowDuration- Global

The WorkflowDuration script include provides methods to calculates the duration (in seconds) based on the variables of a workflow activity. It is an interface between Workflow Timer() and DurationCalculator().

Parent Topic:Server API reference

WorkflowDuration - addSeconds(GlideRecord record, Number amount)

Adds the number of seconds to the specified start date/time.

NameTypeDescription
recordGlideRecorddescription
amountNumberamount
TypeDescription
BooleanTrue, if object was successfully created.

WorkflowDuration - calculate(GlideRecord record)

Calculates the number of seconds and the due date.

NameTypeDescription
recordGlideRecordThe record that contains the fields with the schedule, timezone, and date/time information. This is almost always activity.vars.__var_record__.
TypeDescription
void 

WorkflowDuration - calculateTimeLeft(GlideRecord record)

Calculates the number of seconds remaining to the specified end date/time.

NameTypeDescription
recordGlideRecordThe record that contains the fields with the schedule, timezone, and date/time information. This is almost always activity.vars.__var_record__.
TypeDescription
void 

WorkflowDuration - getEndDateTime( )

Returns the end date/time set by a call to calculate(record).

NameTypeDescription
None  
TypeDescription
GlideDateTimeThe end date/time.

WorkflowDuration - getSeconds( )

Returns the seconds value that was set by a call to calculate(record).

NameTypeDescription
None  
TypeDescription
NumberThe number of seconds set by a call to calculate(record).

WorkflowDuration - getTotalSeconds( )

Returns the totalSeconds value that was set by a call to calculate(record).

NameTypeDescription
None  
TypeDescription
NumberThe total number of seconds set by a call to calculate(record).

WorkflowDuration - setEndDateTime(String dt)

Sets the end date/time to use when calculating the remaining time.

To convert the value into the GlideDateTime internal format, use GlideDateTime.getValue().

NameTypeDescription
dtStringThe end date/time to use.
TypeDescription
void 

WorkflowDuration - setEndDateTime(GlideDateTime dt)

Sets the end date/time to use when calculating the remaining time.

To convert the value into the GlideDateTime internal format, use GlideDateTime.getValue().

NameTypeDescription
dtGlideDateTimeThe end date/time to use.
TypeDescription
void 

WorkflowDuration - setStartDateTime(String dt)

Sets the start date/time to use in the calculations.

NameTypeDescription
dtStringThe start date/time to use, in GMT.
TypeDescription
void 

WorkflowDuration - setStartDateTime(GlideDateTime dt)

Sets the start date/time to use in the calculations.

To convert the value into the GlideDateTime internal format, use GlideDateTime.getValue().

NameTypeDescription
dtGlideDateTimeThe start date/time to use.
TypeDescription
void 

WorkflowDuration - setUsedSecs(Number secs)

Sets the used seconds compensation, where the number of seconds is the number of seconds inside of any schedule.

Can be a -ve number, which extends the duration.

NameTypeDescription
secsNumberThe number of used seconds to set.
TypeDescription
void 

WorkflowDuration - setWorkflow(Object schedule, Object timezone)

Sets the workflow schedule/timezone. Used for schedule_type workflow_schedule and timezone_type workflow_timezone).

NameTypeDescription
scheduleObjectThe schedule to use. Usually from the workflow context.schedule.
timezoneObjectThe timezone to use. Usually from the workflow context.timezone.
TypeDescription
void