{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1116,"path":"api-reference/server-api-reference/c_TaskStateUtil.md","title":null,"bundle":null,"doc_type":null,"release":null,"body":"---\ntitle: TaskStateUtil - Global\ndescription: The TaskStateUtil script include provides methods for working with task-type table state attributes.Creates a TaskStateUtil object.The name of the attribute that identifies default work state.The name of the attribute that identifies the default close state.The name of the attribute that identifies inactive states.The value of the default close state is Closed Complete on the Task table.The value of the default work state is Work in progress on the Task table.The values of the default inactive states: Closed Complete, Closed Incomplete, Closed Skipped on the Task table.Returns the value for the default closed state.Returns the value for the default work state.Returns a list of the inactive state values.Returns the active status of the specified state.Decides whether the mark closed business rule should be run or not.Decides whether the task closer business rule should be run or not.Decides whether the task reopener business rule should be run or not.Enables the user to specify their own default work state.\nlocale: en-US\ncanonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/c\\_TaskStateUtil.html\nrelease: australia\nproduct: Server API Reference\nclassification: server-api-reference\ntopic_type: concept\nlast_updated: \"2026-03-12\"\nreading_time_minutes: 4\nbreadcrumb: [Server API reference, API reference, API implementation and reference]\n---\n\n# TaskStateUtil- Global\n\nThe TaskStateUtil script include provides methods for working with task-type table state attributes.\n\nThis 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.\n\nYou can call the TaskStateUtil script include in any server script to determine inactive states, default work, or default close states for a table.\n\nThe 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.\n\nThese attributes can be defined on the task.state dictionary element or a dictionary override for extended task tables.\n\n<table id=\"table_hv2_51h_1s\"><thead><tr><th>\n\nAttribute\n\n</th><th>\n\nDefinition\n\n</th></tr></thead><tbody><tr><td>\n\nclose\\_states\n\n</td><td>\n\nSemicolon delimited list of state values that are inactive, used to identify whether the task should be set to active or inactive.\n\n</td></tr><tr><td>\n\ndefault\\_close\\_state\n\n</td><td>\n\nOptional. 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.\n\n</td></tr><tr><td>\n\ndefault\\_work\\_state\n\n</td><td>\n\nOptional. 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.\n\n</td></tr></tbody>\n</table>**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## TaskStateUtil - TaskStateUtil\\(GlideRecord task\\)\n\nCreates a TaskStateUtil object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|task|GlideRecord|This must be a GlideRecord from a task table.|\n\n```\nvar stateUtil = new TaskStateUtil(current);\n```\n\n## TaskStateUtil - ATTR\\_DEFAULT\\_WORK\n\nThe name of the attribute that identifies default work state.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ATTR\\_DEFAULT\\_WORK|String|Identifies default work state. Value: default\\_work\\_state|\n\n## TaskStateUtil - ATTR\\_DEFAULT\\_CLOSE\n\nThe name of the attribute that identifies the default close state.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ATTR\\_DEFAULT\\_CLOSE|String|Identifies the default close state. Value: default\\_close\\_state|\n\n## TaskStateUtil - ATTR\\_INACTIVE\\_STATES\n\nThe name of the attribute that identifies inactive states.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ATTR\\_INACTIVE\\_STATES|String|Identifies inactive states. Value: close\\_states|\n\n## TaskStateUtil - SYSTEM\\_DEFAULT\\_CLOSE\n\nThe value of the default close state is Closed Complete on the Task table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|SYSTEM\\_DEFAULT\\_CLOSE|Integer|Value of the default close state is Closed Complete on the Task table. Value: 3|\n\n## TaskStateUtil - SYSTEM\\_DEFAULT\\_WORK\n\nThe value of the default work state is Work in progress on the Task table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|SYSTEM\\_DEFAULT\\_WORK|Integer|Value of the default work state is Work in progress on the Task table. Value: 2|\n\n## TaskStateUtil - SYSTEM\\_INACTIVE\\_STATES\n\nThe values of the default inactive states: Closed Complete, Closed Incomplete, Closed Skipped on the Task table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|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|\n\n## TaskStateUtil - getDefaultCloseState\n\nReturns the value for the default closed state.\n\nThe default closed state value is 3 if the default\\_close\\_state attribute has not been specified.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|State value representing the closed state.|\n\n```\nvar stateUtil = new TaskStateUtil(current);\n//get the close state\nvar defaultCloseState =  stateUtil.getDefaultCloseState();\ncurrent.state = defaultCloseState;\n```\n\n## TaskStateUtil - getDefaultWorkState\\(\\)\n\nReturns the value for the default work state.\n\nThe default work state value is 2 if the default\\_work\\_state attribute has not been specified.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|The state value representing the working state.|\n\n```\nvar stateUtil = new TaskStateUtil(current);\n//get the work state\nvar defaultWorkState =  stateUtil.getDefaultWorkState();\ncurrent.state = defaultWorkState;\n```\n\n## TaskStateUtil - getInactiveStates\n\nReturns a list of the inactive state values.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array|Array of state values that are inactive.|\n\n```\nvar stateUtil = new TaskStateUtil(current);\n//get the inactive state values\nvar inactiveStates = stateUtil.getInactiveStates();\n```\n\n## TaskStateUtil - isStateInactive\\(String state\\)\n\nReturns the active status of the specified state.\n\n|Name|Type|Description|\n|----|----|-----------|\n|state|String|The state value to check.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the state is inactive.|\n\n```\nvar stateUtil = new TaskStateUtil(current);\nvar previousStateInactive = stateUtil.isStateInactive(previous.state);\nvar currentStateInactive = stateUtil.isStateInactive(current.state);\n```\n\n## TaskStateUtil - runMarkClosed\n\nDecides whether the **mark closed** business rule should be run or not.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Whether the business rule should be allowed to run or not.|\n\n## TaskStateUtil - runTaskCloser\n\nDecides whether the **task closer** business rule should be run or not.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Determines whether the business rule should be allowed to run or not.|\n\n## TaskStateUtil - runTaskReopener\n\nDecides whether the **task reopener** business rule should be run or not.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|Whether the business rule should be allowed to run or not.|\n\n## TaskStateUtil - setDefaultWorkState\\(String defaultWorkState\\)\n\nEnables the user to specify their own default work state.\n\n|Name|Type|Description|\n|----|----|-----------|\n|defaultWorkState|String|The value to use for the default work state.|\n\n|Type|Description|\n|----|-----------|\n|TaskStateUtil|A self-reference to allow for method chaining.|\n\n"}}