Owner-depending handling of todos


If you want to make certain actions in the processing of tickets depending on the respective owner of the ticket, proceed as follows.

In all scripts the task is the predefined object that represents the processed ticket.

The function task.getOwner() gives back the owner of the ticket as an object of the type ToDoUser.

In order to identify a certain user within the script you use best the User-ID, so that the script will be still validate, even if the username or the mailaddress might be changed. The username or the mailaddress can still be used for comparing purposes.

You can use the following script, if you, for instance, want to handle the User-IDs 1, 2 and 7 different than all others:

if(task.getOwner()!=null &&
 (task.getOwner().getId()==1 ||
  task.getOwner().getId()==2 ||
  task.getOwner().getId()==7)){
    task.description = task.description + "\nSpecial owner...\n";
}

For the case that the ticket might have no current owner, the first line of the script takes a special consideration.

If you want to compare a lot of IDs, you can work with the Java-Class Set or HashSet, which can handle a fair amount of values. To these values are added the IDs as Long-Objects in the following script, so that the comparison within the contains-method of the Sets between the Java-Objects works.

var userIds = new java.util.HashSet();
userIds.add(new java.lang.Long(1));
userIds.add(new java.lang.Long(2));
userIds.add(new java.lang.Long(7));

if(task.getOwner()!=null &&
   userIds.contains(task.getOwner().getId())){
    task.description = task.description + "\nSpecial owner...\n";
}
     

Child Pages