Notification when changing queue

Hi everyone,

I would like to know if that is possible to send a notification when a ticket changing queue BUT send to the former queue admincc not only the admincc of the new queue.

Thanks

Not out of the box as far as I know, but you could do this with an on queue change scrip and perl template. The Perl template would need to look backwards through the ticket transaction history for the any queue change transaction before the most recent one (the transaction that would have kicked off the scrip/template) and when you find one (or the initial transaction) take the queue mentioned there and grab its AdminCC group for popping in the To: field.

I believe the Transaction object contains both old and new values for changes. I haven’t got the reference code to hand, but the Condition should expose the transaction as $tr (iirc). The docs suggest that $tr→OldValue contains the old value of the. RT::Transaction - RT 5.0.8 Documentation - Best Practical will hopefully give a few pointers which you could use to create a User Defined Condition. RT::Condition - RT 5.0.8 Documentation - Best Practical

What about ‘custom action’?

In custom action preparation code in maybe the old queue is availiable and in custom commit code the new one. So you’ll have the same code twice an inform both Admin-CC.

Or you use just commit code and use the old an new value, like @SimonW alreeady mentioned.

With help from KI this code may work:

# Commit Code for a Custom Action in RT 6
# Sends an email to AdminCCs of both the old and new queue on queue change

my $ticket = $self->TicketObj;
my $txn    = $self->TransactionObj;
my @recipients;

if ( $txn->Type eq 'Set' && $txn->Field eq 'Queue' ) {
    # Load old queue
    my $old_queue = RT::Queue->new( $RT::SystemUser );
    $old_queue->Load( $txn->OldValue );
    push @recipients, $old_queue->AdminCcAddresses;

    # Load new queue
    my $new_queue = RT::Queue->new( $RT::SystemUser );
    $new_queue->Load( $txn->NewValue );
    push @recipients, $new_queue->AdminCcAddresses;
}
else {
    # Fallback: use only the current queue
    my $queue = $ticket->QueueObj;
    push @recipients, $queue->AdminCcAddresses;
}

# Remove duplicates
my %seen;
@recipients = grep { !$seen{$_}++ } @recipients;
return 1 unless @recipients;  # nothing to do

# Prepare message
my $subject = "Ticket #" . $ticket->id . " moved between queues";
my $body    = "This is an automated message for AdminCCs of both queues.\n"
            . "Ticket subject: " . $ticket->Subject . "\n"
            . "Old Queue: " . $txn->OldValue . "\n"
            . "New Queue: " . $txn->NewValue . "\n";

# Use RT internal mail system
use RT::Action::SendEmail;

my $mail = RT::Action::SendEmail->new(
    CurrentUser => $RT::SystemUser,
);
$mail->SetSubject($subject);
$mail->SetBody($body);
$mail->SetTo(join(', ', @recipients));

$mail->SendMessage;

return 1;