TaskStateUtil does not evaluate "active" correctly on insert. The business rule Task Active State Management triggers the script include TaskStateUtil, but on insert this script fails.

The Task Active State Management business rule contains:

//set record to inactive (close) if we move from an active state to an inactive state
if (!previousStateInactive && currentStateInactive && { = false;
gs.print(current.getDisplayValue() + ": State changed (" + previous.state.getDisplayValue() + "->" + current.state.getDisplayValue() + "), setting task to inactive");

The rule compares the previous and current state values. If the state changes from an active state to an inactive state, the active field is set to false.

Because the business rule calls this script before the task is created, the script include TaskStateUtil exits on the initialize function (line 36) when creating a new task:

initialize : function(/*GlideRecord*/ task) {
this.task = task;
if (!task || !task.isValidRecord())

As a result, the value "closeStates" in business rule Task Active State Management is undefined and the script of this business rule exits on line 17:

//see if we have at least the close state attribute
if (closeStates == null)

Steps to Reproduce

  1. Create a new table extension from task by navigating to System Definition -> Tables.
  2. Click New.
  3. Add a state value on that table > 10.
    1. Go to the form view of the new table.
    2. Right click on the State field.
    3. Click Show Choice List.
  4. Add a dictionary override on the task State field.
    1. Navigate to System Definition -> Dictionary.
    2. Search for "Table is Task" and "Column name = state" OR
    3. Click the Advanced view related link.
    4. Add close_states=12 to the Attributes field.
    5. Override attributes and give it a value of close_states=12.
  5. Create a new task on table from #1,
  6. Set the state to your new closed value (#2).
  7. Click Save.
    Active is still true.
  8. Create a new task.
  9. Click Save.
  10. Change the state value to the value in #2.
  11. Save again.
    Active is now false.


  1. Navigate to System Definition > Script Includes.
  2. Open the TaskStateUtil script include.
  3. Change the following code in the initialize method:

if (!task || !task.isValidRecord())


if ((!task || !task.isValidRecord()) && (!task.isNewRecord()))

Note: Remove updates from the sys_update_xml table for the script include to keep receiving updates from ServiceNow:

Related Problem: PRB587123

Seen In

Geneva Patch 7

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-05-21 11:34:05