RT_Scrips/SendEmail.txt
2024-12-14 22:18:13 +00:00

74 lines
1.9 KiB
Plaintext

**** Custom condition:
return 0 unless $self->TicketObj->QueueObj->Name eq "test-queue";
# Check https://rt-wiki.bestpractical.com/wiki/CustomConditionSnippets - for solutions
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $type eq "Status"
|| ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $txn->OldValue eq "new";
return 0 unless $txn->NewValue eq "open";
return 1;
**** Custom action preparation code:
require RT::Action::SendEmail;
use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Action::SendEmail);
$self->SetRecipients();
$self->SUPER::Prepare();
$self->SUPER::Commit();
sub SetRecipients {
my $self = shift;
my $ticket = $self->TicketObj;
my ( @To, @PseudoTo, @Cc, @Bcc );
my $arg ='Owner,Requestor,AdminCc,Cc';
##Requestor
push @To, $ticket->Requestors->MemberEmailAddresses;
##FriendlyToLineFormat
#if ( RT->Config->Get('UseFriendlyToLine') ) {
# unless (@To) {
# push @PseudoTo,
# sprintf RT->Config->Get('FriendlyToLineFormat'), $arg, $ticket->id;
# }
#}
my $creator = $self->TransactionObj->CreatorObj->EmailAddress();
#Strip the sender out of the To, Cc and AdminCc and set the
# recipients fields used to build the message by the superclass.
# unless a flag is set
if (RT->Config->Get('NotifyActor')) {
@{ $self->{'To'} } = @To;
@{ $self->{'Cc'} } = @Cc;
@{ $self->{'Bcc'} } = @Bcc;
}
else {
@{ $self->{'To'} } = grep ( lc $_ ne lc $creator, @To );
@{ $self->{'Cc'} } = grep ( lc $_ ne lc $creator, @Cc );
@{ $self->{'Bcc'} } = grep ( lc $_ ne lc $creator, @Bcc );
}
}
1;
**** Custom action commit code: (Useful for diagnostics)
my $ticket = $self->TicketObj;
if ($self->TicketObj->Status() ne "new") {
return 1;
}
$ticket->Comment(Content => 'Script #21 - sending email to requestor');
$ticket->Comment(Content => 'Status is: '.$self->TicketObj->Status());
return 1;