Switch depending on owner


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

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

The call task.getOwner() returns the owner of the ticket - as an object of type ToDoUser.

To identify a specific user in the script, it is best to use their user ID. This means that your script will still work even if the user name or email address is changed, which could also be used here for comparisons.

For example, if you want to treat tickets of owners with IDs 1, 2 and 7 differently than all others, you can do this with the following script:

if(task.getOwner()!=null &&
 (task.getOwner().getId()==1 ||
  task.getOwner().getId()==2 ||
  task.getOwner().getId()==7)){
    task.title="SALES: " + task.title;
   // ...
}

Since the ticket may not have an owner, this case is given special consideration in the first line.