---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# WorkflowDuration - Global

# WorkflowDuration - Global {#ariaid-title1}

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().

## WorkflowDuration - addSeconds(GlideRecord record, Number amount) {#ariaid-title2}

Adds the number of seconds to the specified start date/time.
{#r_WFD-addSeconds_GR_N__table_bvj_gfj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| record | GlideRecord | description |
| amount | Number | amount |
[Table 1. Parameters]

{#r_WFD-addSeconds_GR_N__table_bvj_gfj_rt} {#r_WFD-addSeconds_GR_N__table_cvj_gfj_rt__entry__2}

| Type | Description |
|-|-|
| Boolean | True, if object was successfully created. |
[Table 2. Returns]

{#r_WFD-addSeconds_GR_N__table_cvj_gfj_rt}

## WorkflowDuration - calculate(GlideRecord record) {#ariaid-title3}

Calculates the number of seconds and the due date.
{#r_WFD-calculate_GR__table_y4j_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| record | GlideRecord | The record that contains the fields with the schedule, timezone, and date/time information. This is almost always activity.vars.__var_record__. |
[Table 3. Parameters]

{#r_WFD-calculate_GR__table_y4j_tbj_rt} {#r_WFD-calculate_GR__table_z4j_tbj_rt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_WFD-calculate_GR__table_z4j_tbj_rt}

## WorkflowDuration - calculateTimeLeft(GlideRecord record) {#ariaid-title4}

Calculates the number of seconds remaining to the specified end date/time.
{#r_WFD-calculateTimeLeft_GR__table_apj_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| record | GlideRecord | The record that contains the fields with the schedule, timezone, and date/time information. This is almost always activity.vars.__var_record__. |
[Table 5. Parameters]

{#r_WFD-calculateTimeLeft_GR__table_apj_tbj_rt} {#r_WFD-calculateTimeLeft_GR__table_bpj_tbj_rt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 6. Returns]

{#r_WFD-calculateTimeLeft_GR__table_bpj_tbj_rt}

## WorkflowDuration - getEndDateTime( ) {#ariaid-title5}

Returns the end date/time set by a call to
calculate(record).
{#r_WFD-getEndDateTime__table_sjq_bs1_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 7. Parameters]

{#r_WFD-getEndDateTime__table_sjq_bs1_4t} {#r_WFD-getEndDateTime__table_tjq_bs1_4t__entry__2}

| Type | Description |
|-|-|
| GlideDateTime | The end date/time. |
[Table 8. Returns]

{#r_WFD-getEndDateTime__table_tjq_bs1_4t}

## WorkflowDuration - getSeconds( ) {#ariaid-title6}

Returns the seconds value that was set by a call to
calculate(record).
{#r_WFD-getSeconds__table_q4j_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 9. Parameters]

{#r_WFD-getSeconds__table_q4j_tbj_rt} {#r_WFD-getSeconds__table_r4j_tbj_rt__entry__2}

| Type | Description |
|-|-|
| Number | The number of seconds set by a call to calculate(record). |
[Table 10. Returns]

{#r_WFD-getSeconds__table_r4j_tbj_rt}

## WorkflowDuration - getTotalSeconds( ) {#ariaid-title7}

Returns the totalSeconds value that was set by a call to calculate(record).
{#r_WFD-getTotalSeconds__table_s4j_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 11. Parameters]

{#r_WFD-getTotalSeconds__table_s4j_tbj_rt} {#r_WFD-getTotalSeconds__table_t4j_tbj_rt__entry__2}

| Type | Description |
|-|-|
| Number | The total number of seconds set by a call to calculate(record). |
[Table 12. Returns]

{#r_WFD-getTotalSeconds__table_t4j_tbj_rt}

## WorkflowDuration - setEndDateTime(String dt) {#ariaid-title8}

Sets the end date/time to use when calculating the remaining time.
To convert the value into the GlideDateTime internal format, use
GlideDateTime.getValue().
{#r_WFD-setEndDateTime_S__table_yjq_bs1_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| dt | String | The end date/time to use. |
[Table 13. Parameters]

{#r_WFD-setEndDateTime_S__table_yjq_bs1_4t} {#r_WFD-setEndDateTime_S__table_zjq_bs1_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 14. Returns]

{#r_WFD-setEndDateTime_S__table_zjq_bs1_4t}

## WorkflowDuration - setEndDateTime(GlideDateTime dt) {#ariaid-title9}

Sets the end date/time to use when calculating the remaining time.
To convert the value into the GlideDateTime internal format, use
GlideDateTime.getValue().
{#r_WFD-setEndDateTime_GDT__table_akq_bs1_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| dt | GlideDateTime | The end date/time to use. |
[Table 15. Parameters]

{#r_WFD-setEndDateTime_GDT__table_akq_bs1_4t} {#r_WFD-setEndDateTime_GDT__table_bkq_bs1_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 16. Returns]

{#r_WFD-setEndDateTime_GDT__table_bkq_bs1_4t}

## WorkflowDuration - setStartDateTime(String dt) {#ariaid-title10}

Sets the start date/time to use in the calculations.
{#r_WFD-setStartDateTime_S__table_ujq_bs1_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| dt | String | The start date/time to use, in GMT. |
[Table 17. Parameters]

{#r_WFD-setStartDateTime_S__table_ujq_bs1_4t} {#r_WFD-setStartDateTime_S__table_vjq_bs1_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 18. Returns]

{#r_WFD-setStartDateTime_S__table_vjq_bs1_4t}

## WorkflowDuration - setStartDateTime(GlideDateTime dt) {#ariaid-title11}

Sets the start date/time to use in the calculations.
To convert the value into the GlideDateTime internal format, use
GlideDateTime.getValue().
{#r_WFD-setStartDateTime_GDT__table_wjq_bs1_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| dt | GlideDateTime | The start date/time to use. |
[Table 19. Parameters]

{#r_WFD-setStartDateTime_GDT__table_wjq_bs1_4t} {#r_WFD-setStartDateTime_GDT__table_xjq_bs1_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 20. Returns]

{#r_WFD-setStartDateTime_GDT__table_xjq_bs1_4t}

## WorkflowDuration - setUsedSecs(Number secs) {#ariaid-title12}

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.
{#r_WFD-setUsedSecs_N__table_w4j_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| secs | Number | The number of used seconds to set. |
[Table 21. Parameters]

{#r_WFD-setUsedSecs_N__table_w4j_tbj_rt} {#r_WFD-setUsedSecs_N__table_x4j_tbj_rt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 22. Returns]

{#r_WFD-setUsedSecs_N__table_x4j_tbj_rt}

## WorkflowDuration - setWorkflow(Object schedule, Object timezone) {#ariaid-title13}

Sets the workflow schedule/timezone.
Used for schedule_type
workflow_schedule and timezone_type
workflow_timezone).
{#r_WFD-setWorkflow_O_O__table_u4j_tbj_rt__entry__3}

| Name | Type | Description |
|-|-|-|
| schedule | Object | The schedule to use. Usually from the workflow context.schedule. |
| timezone | Object | The timezone to use. Usually from the workflow context.timezone. |
[Table 23. Parameters]

{#r_WFD-setWorkflow_O_O__table_u4j_tbj_rt} {#r_WFD-setWorkflow_O_O__table_v4j_tbj_rt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 24. Returns]

{#r_WFD-setWorkflow_O_O__table_v4j_tbj_rt}

