AutoCcLastOwner: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
(No difference)

Latest revision as of 15:03, 6 April 2016

AutoCcLastOwner

This scrip adds the previous owner of a ticket to the Cc list when the owner is changed.

Description: AutoCcOwner
Condition: On Owner Change
Action: User Defined
Custom action preparation code:
 my $last_id = $self->TransactionObj->OldValue;
 my $temp_user = RT::User->new();
 $temp_user->Load($last_id);
 my $last_email = $temp_user->EmailAddress();
 $self->TicketObj->AddWatcher( Type => "Cc",
                             Email => $last_email);
 return 1;

Custom action cleanup code:
 return 1;
Template: Global template: Blank

Automatically AdminCc last owner when owner changes to Nobody

When someone moves tickets between queues, the owner may forcibly get changed to Nobody, and then the previous owner loses access to the ticket. This variant of the above scrip will detect this situation and automatically add that previous owner as an AdminCc.

Custom action preparation code:

# only act if the owner was changed to "Nobody"
 my $new_id = $self->TransactionObj->NewValue;
 return 1 unless ($new_id == $RT::Nobody->Id);
 
 # add the previous owner to the AdminCc list
 my $last_id = $self->TransactionObj->OldValue;
 my $temp_user = RT::User->new();
 $temp_user->Load($last_id);
 my $last_email = $temp_user->EmailAddress();
 $self->TicketObj->AddWatcher( Type => "AdminCc",
                             Email => $last_email);
 return 1;