How to Perform Automatic Task Escalation

Generally, escalation of a task is its transition into other state, to the other submitter or raising its priority depending upon the conditions. For example, upon the expiry of deadline, or after a particular time since last refresh. Generally the escalation is done automatically. TrackStudio doesn’t yet have the facility for automatic execution of triggers, but things can be managed without it also.

As an example we will automatically convert the tasks, which are in the state “New” or “In Process” or “Paused”, to the state “Expired” on the next day after the deadline. In this method we will create the computable field for the task of required type, in which through SecuredMessageTriggerBean.create() we will execute the operation, converting the task to the required state (and, for example, reassign it to the submitter of the task). The given field will be computed every time, when it is displayed to the user. So as to prevent it from occurring very frequently, we will configure the permissions for the field in such a way that it is displayed only for a particular group of users.

We will login as root in the default database (‘Requirements Management’). Then we go to ‘Users Management’ and create the role ‘Bot’. We will not set the permissions for it yet.

We go to ‘Users Management’ and create the user. It may be assigned the role ‘Bot’, but it is not mandatory, we can later assign it through access to the tasks.

We go back to 'Task Management’. We will make the script for escalation of Errors, therefore we go to this workflow.

We create a new state ‘Expired'. Then we create the type of operation ‘escalate’ with steps:

We go back to 'Tasks Management’. We will make the script for escalation of Errors, so we go to this workflow.

We create a new state ‘Expired'. Then we create the type of operation ‘escalate’ with transitions:

Permissions have to be set in such a way that only bots could execute this operation.

Similarly, we will need the operation, which converts the task from the state ‘Expired’ to another. It can be executed, for example, by managers only.

The script is:

package scripts.task_custom_field_value;

import com.trackstudio.exception.GranException;
import com.trackstudio.external.TaskUDFValueScript;
import com.trackstudio.secured.SecuredMessageTriggerBean;
import com.trackstudio.secured.SecuredTaskBean;

import java.util.Calendar;

Scripts will convert the tasks, which are in the state “New” or “In Process” or “Paused” to the state “Expired” on * the next day after the deadline
public class Escalate implements TaskUDFValueScript {

    public Object calculate(SecuredTaskBean securedTaskBean) throws GranException {
        Calendar deadline = securedTaskBean.getDeadline();
        String status = securedTaskBean.getStatus().getName();
        if (deadline != null && (status.equals("New") || status.equals("In process") || status.equals("Paused"))) {
            Calendar now = Calendar.getInstance();

            now.set(Calendar.HOUR_OF_DAY, 0);
            now.set(Calendar.MINUTE, 0);
            now.set(Calendar.SECOND, 0);
            now.set(Calendar.MILLISECOND, 0);

            deadline.set(Calendar.HOUR_OF_DAY, 0);
            deadline.set(Calendar.MINUTE, 0);
            deadline.set(Calendar.SECOND, 0);
            deadline.set(Calendar.MILLISECOND, 0);

            long l = now.getTimeInMillis() - deadline.getTimeInMillis();

            int days = (int) (l / (24 * 60 * 60 * 1000));
            if (days > 0) {
                // convert
                String mstatusId = CSVImport.findMessageTypeIdByName("escalate", securedTaskBean.getCategory().getName());

                 * We create SecuredMessageTriggerBean
                SecuredMessageTriggerBean createMessage = new SecuredMessageTriggerBean(
                        null /* Identifier */,
                        "task was expired" /* comments text */,
                        Calendar.getInstance() /* operation execution time */,
                        null /* spent time */,
                        securedTaskBean.getDeadline() /* Task deadline */,
                        securedTaskBean.getBudget() /* budget */,
                        securedTaskBean.getId() /* task */,
                        securedTaskBean.getSecure().getUserId() /* submitter of operation*/,
                        null /* resolution */,
                        securedTaskBean.getPriorityId() /* priority */,
                        securedTaskBean.getHandlerId() /* assignees*/,
                        securedTaskBean.getHandlerUserId() /* assignee*/,
                        securedTaskBean.getHandlerGroupId() /* assignee, if group is to be set as assignee */,
                        mstatusId /* type of operation */,
                        null /* Map with custome fields */,
                        securedTaskBean.getSecure() /* SessionContext */,
                        null /* attachments */);
                 * execute

                return "expired";


        return "active";


We create the custom field of type ‘String’, to which we attach this script. Permissions to the field are set in such a way that only Bots could browse them.

Now every time, when any of the bots will browse this field in the task, the script will run and deadline will be checked. However even robot will unlikely browse all the tasks at particular time. We will need event notification.

First of all, we give the bot ‘Bot Escalator’ access to the project, with a mandatory role ‘Bot’. Then we log in the system as this user and create the filter, which displays all the tasks in the state ‘New’, ‘In Process’ and ‘Paused’ and in which the deadline took place 1 minute ago or earlier.

Note! In the conditions of filtering, the field, to which above mentioned script is attached, needs to be activated. For this purpose, you can specify any condition for this field. At the time of condition checking, the script is executed and the tasks are moved to the required state.

After this, we create the subscription to this filter by the user escalate.

Now everyday at 8 morning the expired tasks in this project will be shifted to the state ‘Expired’