AutoChangeQueue: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
No edit summary
Line 9: Line 9:
  Custom action preparation code: return 1;
  Custom action preparation code: return 1;
  Custom action cleanup code:
  Custom action cleanup code:
<syntaxhighlight lang="perl" line="1" >
   my $group = 'admin';
   my $group = 'admin';
   my $newqueue = 'admin';
   my $newqueue = 'admin';
Line 14: Line 17:
   # si pas dans une action Take alors on sort
   # si pas dans une action Take alors on sort
   return 1
   return 1
     unless $self-&gt;TransactionObj-&gt;Type eq 'Take';
     unless $self->TransactionObj->Type eq 'Take';
   
   
   my $PrincipalObj = RT::Principal-&gt;new( $self-&gt;TransactionObj-&gt;CreatorObj );
   my $PrincipalObj = RT::Principal->new( $self->TransactionObj->CreatorObj );
   $PrincipalObj-&gt;Load( $self-&gt;TransactionObj-&gt;CreatorObj-&gt;Id );
   $PrincipalObj->Load( $self->TransactionObj->CreatorObj->Id );
   
   
   my $groupobj = RT::Group-&gt;new($self-&gt;TransactionObj-&gt;CreatorObj );
   my $groupobj = RT::Group->new($self->TransactionObj->CreatorObj );
   $groupobj-&gt;LoadUserDefinedGroup($group);
   $groupobj->LoadUserDefinedGroup($group);
   my $HasMember = $groupobj-&gt;HasMemberRecursively( $PrincipalObj );
   my $HasMember = $groupobj->HasMemberRecursively( $PrincipalObj );
   if ($HasMember) {
   if ($HasMember) {
       $RT::Logger-&gt;info("Ticket took by an admin : new ticket in admin queue");
       $RT::Logger->info("Ticket took by an admin : new ticket in admin queue");
       my ($status, $msg) = $self-&gt;TicketObj-&gt;SetQueue($newqueue);
       my ($status, $msg) = $self->TicketObj->SetQueue($newqueue);
       unless ($status) {
       unless ($status) {
           $RT::Logger-&gt;warning("unable to set new queue");
           $RT::Logger->warning("unable to set new queue");
           return undef;
           return undef;
       }
       }
Line 33: Line 36:
   return 1;
   return 1;
   
   
</syntaxhighlight>
  Template: Global template: Blank
  Template: Global template: Blank

Revision as of 07:19, 1 August 2016

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:
   my $group = 'admin';
   my $newqueue = 'admin';
 
   # si pas dans une action Take alors on sort
   return 1
     unless $self->TransactionObj->Type eq 'Take';
 
   my $PrincipalObj = RT::Principal->new( $self->TransactionObj->CreatorObj );
   $PrincipalObj->Load( $self->TransactionObj->CreatorObj->Id );
 
   my $groupobj = RT::Group->new($self->TransactionObj->CreatorObj );
   $groupobj->LoadUserDefinedGroup($group);
   my $HasMember = $groupobj->HasMemberRecursively( $PrincipalObj );
   if ($HasMember) {
      $RT::Logger->info("Ticket took by an admin : new ticket in admin queue");
       my ($status, $msg) = $self->TicketObj->SetQueue($newqueue);
       unless ($status) {
          $RT::Logger->warning("unable to set new queue");
          return undef;
       }
   }
 
   return 1;
Template: Global template: Blank