- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Task [task] is one of the core tables provided with the base system. It provides a series of standard fields used on each of the tables that extend it, such as the Incident [incident] and Problem [problem] tables. In addition, any table which extends task can take advantage of task-specific functionality for driving tasks. Out of the box, there are over 30 tables that extend the task table, some of the most famous ones are:
- incident
- change_request
- sc_req_item, sc_request
- sc_task and change_task
Understanding the different parts that control the task table "close" state and active values is very important and can save a lot of troubleshooting time.
A typical scenario where custom "close" state seems not to work
Let's pretend you have defined some additional Choices for the State field (see Choice lists for details) of a task table like 'Implemented successfully' or 'Implementation failed' etc. Now the state is 'Closed' and it no longer has the default value of 3. Rather, the default value is some other value like 9. You then create a new workflow, business rule, or any other script that runs on the task table (or a table that extends it). You're trying to set a particular task's state to Closed (9). You find that the action was completed successfully but to your surprise, the task's state is set to the default value (3).
Understanding how the state value is determined and the relation between the active flag and the state value is crucial to solving this issue. You also need to understand which business rules are involved in this process to help you properly customize you task "close" states.
Understanding the relation between the inactive and the "close" task states
The 'mark closed' business rule sets the task's active flag to false when the task's state changes to an inactive state. An inactive state is a state that is assigned to a given task when it is no longer active (ie closed or cancelled) In the base system, there are three task states that are considered inactive states.These are:
- Closed Complete (3)
- Closed Incomplete (4)
- Closed Skipped (7)
These values can be overridden by the close_states attribute of the task's state field.
The 'mark closed' business rule runs on the task table before insert and update and it has the following condition:
new TaskStateUtil(current).runMarkClosed()
Which will return true and executes the following code if the state is one of the default inactive states above or one of the states defined by the close_states attribute:
current.active = false;
Understanding why your custom task "close" state value being overridden
The short answer to this is that it is due to the 'Task closer' business rule. Out of the box, the default closed state has the value 3 (Closed Complete) which can be overridden by the default_close_state attribute of the task's state field.
Now, the task's state is set to the system default 3 (Closed Complete) or the User default (set by the default_close_state attribute) by the 'Task closer' business rule which has the following condition:
new TaskStateUtil(current).runTaskCloser()
This will return true and executes the following code if the task's active flag is set to false, state is still in an open state (any state that is not considered an inactive state) and is in a supported table, which, out of the box, is task table or any table extending task table except 'dmn_demand', 'idea' tables:
current.state = new TaskStateUtil(current).getDefaultCloseState();
This will set the state to the system default value for "Closed" which is 3. or the dictionary override value for default_close_state on the task's table.
How to set the close_states and default_close_state attributes
In order for you to be able to use a different close state than the default of the box one you will need to use dictionary overrides (see Dictionary override)which will enable you to set to different values of these attributes for each task table:
- Open the Dictionary Entry for the state field of the task table.
- Add a new Dictionary override and use the following
- Table: change request[change_request] (use any other table as needed)
- Override attributes > checked
- Attributes > default_close_state=5 (use any other value as needed), or
- Attributes > close_states=7;8;9 (use any other value as needed), or
- Attributes > default_close_state=5, close_states=7;8;9
- Click submit.
Understanding how the active and state values of your task table is set and overridden is crucial for creating successful workflows and scripts. It will enable you to successfully manage your tasks active and close states when the out-of-the-box settings do not satisfy your business requirements saving you a lot of troubleshooting time otherwise.
- 24,825 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.