RT_Scrips/Scrip26.txt

69 lines
1.7 KiB
Plaintext

#Enhanced send equirer email:
#Custom condition:
# This script first checks if the inquirer has already been messaged
# Then assembles email
# Sends email
# Sets flag that inquirer has already been messaged.
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $self->TicketObj->FirstCustomFieldValue('Inquirer Auto-Response Sent') ne 'Yes';
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
return 0 unless $self->TicketObj->Status eq "Inquirer Autoresponse Sent";
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;
push @To, $ticket->FirstCustomFieldValue('Inquirer Email');
my $creator = "Davis Admin";
@{ $self->{'To'} } = @To;
}
my $value_set = $self->TicketObj->AddCustomFieldValue(Field => 'Inquirer Auto-Response Sent', Value => 'Yes');
# $self->TicketObj->Comment(Content => 'AUTO Scrip #26 changing sent status:- '.$value_set);
unless ($value_set) {
$RT::Logger->error("Failed to set custom field value for 'Inquirer Auto-Response Sent'");
return 0;
}
$RT::Logger->error($self->TransactionObj->Type);
$RT::Logger->error($self->TransactionObj->NewValue);
1;
# Custom Commit Code:
# Now move ticket to next step as required.
my $ticket = $self->TicketObj;
$ticket->Comment(Content => 'AUTO Scrip #26 - sent email to inquirer');
my ($status, $msg) =$ticket->SetStatus('Redacted Facilitator Email Sent');
1;