AutoChangeQueue

From Request Tracker Wiki
Jump to navigation Jump to search

Overview

I've got two queues and two groups, one for admin and one for production. If an admin group member takes a ticket in the production queue, I want the ticket to go automatically into the admin queue. Just create this scrip in the production queue:

Description: AutoChangeQueue

Condition: On Owner Change
Custom condition:
Action: User Defined
Custom action preparation code: return 1;
Custom action cleanup code:
 1 my $group = 'admin';
 2 my $newqueue = 'admin';
 3 
 4 # si pas dans une action Take alors on sort
 5 return 1
 6  unless $self->TransactionObj->Type eq 'Take';
 7 
 8 my $PrincipalObj = RT::Principal->new( $self->TransactionObj->CreatorObj );
 9 $PrincipalObj->Load( $self->TransactionObj->CreatorObj->Id );
10 
11 my $groupobj = RT::Group->new($self->TransactionObj->CreatorObj );
12 $groupobj->LoadUserDefinedGroup($group);
13 my $HasMember = $groupobj->HasMemberRecursively( $PrincipalObj );
14 if ($HasMember) {
15   $RT::Logger->info("Ticket took by an admin : new ticket in admin queue");
16    my ($status, $msg) = $self->TicketObj->SetQueue($newqueue);
17    unless ($status) {
18       $RT::Logger->warning("unable to set new queue");
19       return undef;
20    }
21 }
22 
23 return 1;

Template: Global template: Blank