---
sourceDocument: Australia API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/api-reference

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# TaskStateUtil - Global

# TaskStateUtil - Global {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 Minuten Lesedauer

The TaskStateUtil script include provides methods for working with task-type table state attributes.

This script include is primarily used by the Task Active State Management business rule to set the active field based on state changes. Configurations are defined in the task.state dictionary element, usually using dictionary
overrides since state values vary by table.

You can call the TaskStateUtil script include in any server script to determine inactive states, default work, or default close states for a table.

The required attributes are defined on the planned_task table so all planned task types are
supported. We will eventually add the attributes to other task types and eventually the base task
table. You are free to do this if you want to leverage this feature now.  
These attributes can be defined on the task.state dictionary element or a dictionary override for extended task tables.{#c_TaskStateUtil__table_hv2_51h_1s__entry__2}

| Attribute | Definition |
|-|-|
| close_states | Semicolon delimited list of state values that are inactive, used to identify whether the task should be set to active or inactive. |
| default_close_state | Optional. Attribute to define the state value of the default close state if you want to define business rules that automatically close a task. Default: 3, typically Closed Complete if attribute is not defined. |
| default_work_state | Optional. Attribute to define the state value of the default working state if you want to define business rules that automatically set a task for working. Default: 2, typically Work in Progress if the attribute is not defined. |
[Tabelle : 1. Related Attributes]

{#c_TaskStateUtil__table_hv2_51h_1s}

## TaskStateUtil - TaskStateUtil(GlideRecord task) {#ariaid-title2}

Creates a TaskStateUtil object.
{#r_TaskStateUtilTaskStateUtil_GlideRecord__table_j52_1ch_1s__entry__3}

| Name | Type | Description |
|-|-|-|
| task | GlideRecord | This must be a GlideRecord from a task table. |
[Tabelle : 2. Parameters]

{#r_TaskStateUtilTaskStateUtil_GlideRecord__table_j52_1ch_1s}  

    var stateUtil = new TaskStateUtil(current);

## TaskStateUtil - ATTR_DEFAULT_WORK {#ariaid-title3}

The name of the attribute that identifies default work state.
{#r_TaskStateUtil-ATTR_DEFAULT_WORK__table_lk2_qgk_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| ATTR_DEFAULT_WORK | String | Identifies default work state. Value: default_work_state |
[Tabelle : 3. Field]

{#r_TaskStateUtil-ATTR_DEFAULT_WORK__table_lk2_qgk_xs}

## TaskStateUtil - ATTR_DEFAULT_CLOSE {#ariaid-title4}

The name of the attribute that identifies the default close state.
{#r_TaskStateUtil-ATTR_DEFAULT_CLOSE__table_och_chk_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| ATTR_DEFAULT_CLOSE | String | Identifies the default close state. Value: default_close_state |
[Tabelle : 4. Field]

{#r_TaskStateUtil-ATTR_DEFAULT_CLOSE__table_och_chk_xs}

## TaskStateUtil - ATTR_INACTIVE_STATES {#ariaid-title5}

The name of the attribute that identifies inactive states.
{#r_TaskStateUtil-ATTR_INACTIVE_STATES__table_cbk_g2k_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| ATTR_INACTIVE_STATES | String | Identifies inactive states. Value: close_states |
[Tabelle : 5. Field]

{#r_TaskStateUtil-ATTR_INACTIVE_STATES__table_cbk_g2k_xs}

## TaskStateUtil - SYSTEM_DEFAULT_CLOSE {#ariaid-title6}

The value of the default close state is Closed Complete on the Task table.
{#r_TaskStateUtil-SYSTEM_DEFAULT_CLOSE__table_ldn_3hk_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| SYSTEM_DEFAULT_CLOSE | Integer | Value of the default close state is Closed Complete on the Task table. Value: 3 |
[Tabelle : 6. Field]

{#r_TaskStateUtil-SYSTEM_DEFAULT_CLOSE__table_ldn_3hk_xs}

## TaskStateUtil - SYSTEM_DEFAULT_WORK {#ariaid-title7}

The value of the default work state is Work in progress on the Task table.
{#r_TaskStateUtil-SYSTEM_DEFAULT_WORK__table_n1l_phk_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| SYSTEM_DEFAULT_WORK | Integer | Value of the default work state is Work in progress on the Task table. Value: 2 |
[Tabelle : 7. Field]

{#r_TaskStateUtil-SYSTEM_DEFAULT_WORK__table_n1l_phk_xs}

## TaskStateUtil - SYSTEM_INACTIVE_STATES {#ariaid-title8}

The values of the default inactive states: Closed Complete, Closed Incomplete, Closed
Skipped on the Task table.
{#r_TaskStateUtil-SYSTEM_INACTIVE_STATES__table_p4w_yhk_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| SYSTEM_INACTIVE_STATES | Integer array | Values of the default inactive states: Closed Complete, Closed Incomplete, Closed Skipped on the Task table. Value: 3, 4, 7 |
[Tabelle : 8. Field]

{#r_TaskStateUtil-SYSTEM_INACTIVE_STATES__table_p4w_yhk_xs}

## TaskStateUtil - getDefaultCloseState {#ariaid-title9}

Returns the value for the default closed state.
The default closed state value is 3 if the default_close_state attribute has not been
specified.
{#r_TaskStateUtilGetDefaultCloseState__table_nft_hgh_1s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 9. Parameters]

{#r_TaskStateUtilGetDefaultCloseState__table_nft_hgh_1s} {#r_TaskStateUtilGetDefaultCloseState__table_oft_hgh_1s__entry__2}

| Type | Description |
|-|-|
| Number | State value representing the closed state. |
[Tabelle : 10. Returns]

{#r_TaskStateUtilGetDefaultCloseState__table_oft_hgh_1s}  

    var stateUtil = new TaskStateUtil(current);
    //get the close state
    var defaultCloseState =  stateUtil.getDefaultCloseState();
    current.state = defaultCloseState;

## TaskStateUtil - getDefaultWorkState() {#ariaid-title10}

Returns the value for the default work state.
The default work state value is 2 if the default_work_state attribute has not been
specified.
{#r_TaskStateUtilGetDefaultWorkState__table_cjr_22h_1s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 11. Parameters]

{#r_TaskStateUtilGetDefaultWorkState__table_cjr_22h_1s} {#r_TaskStateUtilGetDefaultWorkState__table_djr_22h_1s__entry__2}

| Type | Description |
|-|-|
| Number | The state value representing the working state. |
[Tabelle : 12. Returns]

{#r_TaskStateUtilGetDefaultWorkState__table_djr_22h_1s}  

    var stateUtil = new TaskStateUtil(current);
    //get the work state
    var defaultWorkState =  stateUtil.getDefaultWorkState();
    current.state = defaultWorkState;

## TaskStateUtil - getInactiveStates {#ariaid-title11}

Returns a list of the inactive state values.
{#r_TaskStateUtilGetInactiveStates__table_jtf_zgh_1s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 13. Parameters]

{#r_TaskStateUtilGetInactiveStates__table_jtf_zgh_1s} {#r_TaskStateUtilGetInactiveStates__table_ktf_zgh_1s__entry__2}

| Type | Description |
|-|-|
| Array | Array of state values that are inactive. |
[Tabelle : 14. Returns]

{#r_TaskStateUtilGetInactiveStates__table_ktf_zgh_1s}  

    var stateUtil = new TaskStateUtil(current);
    //get the inactive state values
    var inactiveStates = stateUtil.getInactiveStates();

## TaskStateUtil - isStateInactive(String state) {#ariaid-title12}

Returns the active status of the specified state.
{#r_TaskStateUtilIsStateInactive_String__table_bzq_ndh_1s__entry__3}

| Name | Type | Description |
|-|-|-|
| state | String | The state value to check. |
[Tabelle : 15. Parameters]

{#r_TaskStateUtilIsStateInactive_String__table_bzq_ndh_1s} {#r_TaskStateUtilIsStateInactive_String__table_czq_ndh_1s__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the state is inactive. |
[Tabelle : 16. Returns]

{#r_TaskStateUtilIsStateInactive_String__table_czq_ndh_1s}  

    var stateUtil = new TaskStateUtil(current);
    var previousStateInactive = stateUtil.isStateInactive(previous.state);
    var currentStateInactive = stateUtil.isStateInactive(current.state);

## TaskStateUtil - runMarkClosed {#ariaid-title13}

Decides whether the mark closed business rule should be run or
not.
{#r_TaskStateUtilrunMarkClosed__table_xvr_nbq_2s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 17. Parameters]

{#r_TaskStateUtilrunMarkClosed__table_xvr_nbq_2s} {#r_TaskStateUtilrunMarkClosed__table_yvr_nbq_2s__entry__2}

| Type | Description |
|-|-|
| Boolean | Whether the business rule should be allowed to run or not. |
[Tabelle : 18. Returns]

{#r_TaskStateUtilrunMarkClosed__table_yvr_nbq_2s}

## TaskStateUtil - runTaskCloser {#ariaid-title14}

Decides whether the task closer business rule should be run or
not.
{#r_TaskStateUtil-runTaskCloser__table_ad5_rrj_xs__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 19. Parameters]

{#r_TaskStateUtil-runTaskCloser__table_ad5_rrj_xs} {#r_TaskStateUtil-runTaskCloser__table_bd5_rrj_xs__entry__2}

| Type | Description |
|-|-|
| Boolean | Determines whether the business rule should be allowed to run or not. |
[Tabelle : 20. Returns]

{#r_TaskStateUtil-runTaskCloser__table_bd5_rrj_xs}

## TaskStateUtil - runTaskReopener {#ariaid-title15}

Decides whether the task reopener business rule should be run or
not.
{#r_TaskStateUtilrunTaskReopener__table_ldl_4bq_2s__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 21. Parameters]

{#r_TaskStateUtilrunTaskReopener__table_ldl_4bq_2s} {#r_TaskStateUtilrunTaskReopener__table_mdl_4bq_2s__entry__2}

| Type | Description |
|-|-|
| Boolean | Whether the business rule should be allowed to run or not. |
[Tabelle : 22. Returns]

{#r_TaskStateUtilrunTaskReopener__table_mdl_4bq_2s}

## TaskStateUtil - setDefaultWorkState(String defaultWorkState) {#ariaid-title16}

Enables the user to specify their own default work state.
{#r_TSU-setDefaultWorkState_S__table_g1l_jcq_2s__entry__3}

| Name | Type | Description |
|-|-|-|
| defaultWorkState | String | The value to use for the default work state. |
[Tabelle : 23. Parameters]

{#r_TSU-setDefaultWorkState_S__table_g1l_jcq_2s} {#r_TSU-setDefaultWorkState_S__table_h1l_jcq_2s__entry__2}

| Type | Description |
|-|-|
| TaskStateUtil | A self-reference to allow for method chaining. |
[Tabelle : 24. Returns]

{#r_TSU-setDefaultWorkState_S__table_h1l_jcq_2s}

