Compare commits
2 Commits
9522d0fb63
...
677ce469c7
Author | SHA1 | Date | |
---|---|---|---|
|
677ce469c7 | ||
|
2905301976 |
74
Scrip25.txt
Normal file
74
Scrip25.txt
Normal file
@ -0,0 +1,74 @@
|
||||
#Check and change queue as required
|
||||
|
||||
# On create
|
||||
# User Defined
|
||||
|
||||
my $txn = $self->TransactionObj;
|
||||
my $type = $txn->Type;
|
||||
my $ticket = $self->TicketObj;
|
||||
|
||||
if ($ticket->Status() ne "New") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
# Custom action
|
||||
|
||||
return 1;
|
||||
|
||||
# Commit:
|
||||
|
||||
my $ticket = $self->TicketObj;
|
||||
my $queue = $ticket->FirstCustomFieldValue('Hub Queue');
|
||||
|
||||
#if ($ticket->Status() ne "new") {
|
||||
# return 1;
|
||||
#}
|
||||
|
||||
|
||||
#This potentially means that the email is spam if it's missing, so we could potentially move it somewhere else?
|
||||
if ($ticket->FirstCustomFieldValue('Inquirer Email') eq '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$ticket->Comment(Content => 'AUTO: Scrip #25New ticket. Current queue is: '.$ticket->QueueObj->Name.'. Required queue is: '.$queue);
|
||||
|
||||
#Now change Queue
|
||||
#Get current queue?:
|
||||
if (($queue eq $ticket->QueueObj->Name) || ($queue eq "")) {
|
||||
$ticket->Comment(Content => 'AUTO: Scrip #25 Leaving in current queue');
|
||||
my ($status, $msg) =$ticket->SetStatus('Inquirer Autoresponse Sent');
|
||||
|
||||
} else {
|
||||
my ($status, $msg) = $ticket->SetQueue( $queue);
|
||||
if ($status == 0) {
|
||||
$ticket->Comment(Content => 'AUTO: Scrip #25 Error changing queue to: '.$queue.' - '.$msg);
|
||||
} else {
|
||||
$ticket->Comment(Content => 'AUTO: Scrip #25 Changing queue to: '.$queue);
|
||||
my ($status, $msg) =$ticket->SetStatus('Inquirer Autoresponse Sent');
|
||||
}
|
||||
}
|
||||
|
||||
# Check and assign Queue Managers =======
|
||||
my $groupname;
|
||||
if (( $ticket->QueueObj->Name) eq "Contact Facilitator") {
|
||||
$groupname="Inquiries - Contact Facilitator";
|
||||
} elsif (( $ticket->QueueObj->Name) eq "Contact North America") {
|
||||
$groupname="Inquiries - Hub North America";
|
||||
} else {
|
||||
$groupname="Inquiries - Test";
|
||||
}
|
||||
|
||||
my $groupObj = RT::Group->new($RT::SystemUser);
|
||||
$groupObj->LoadUserDefinedGroup($groupname);
|
||||
return undef unless $groupObj;
|
||||
|
||||
my $role = RT::CustomRole->new( $self->CurrentUser );
|
||||
$role->Load( "Queue Managers" );
|
||||
|
||||
my ($success, $msg) = $self->TicketObj->AddWatcher( Type => $role->GroupType, PrincipalId => $groupObj->Id );
|
||||
|
||||
return 1;
|
||||
|
68
Scrip26.txt
Normal file
68
Scrip26.txt
Normal file
@ -0,0 +1,68 @@
|
||||
#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;
|
||||
|
72
Scrip27.txt
Normal file
72
Scrip27.txt
Normal file
@ -0,0 +1,72 @@
|
||||
# Enhanced send facilitator initial email
|
||||
# Custom conditions
|
||||
# Custom Email
|
||||
# Template - Send Facilitator Email
|
||||
|
||||
# Conditions:
|
||||
|
||||
# This script first checks for correct status
|
||||
# Then assembles email
|
||||
# Sends email
|
||||
|
||||
my $txn = $self->TransactionObj;
|
||||
my $type = $txn->Type;
|
||||
|
||||
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
|
||||
return 0 unless $self->TicketObj->Status eq "Redacted Facilitator Email Sent";
|
||||
return 1;
|
||||
|
||||
|
||||
# Custom preparation:
|
||||
|
||||
|
||||
require RT::Action::SendEmail;
|
||||
use strict;
|
||||
use vars qw/@ISA/;
|
||||
@ISA = qw(RT::Action::SendEmail);
|
||||
|
||||
#STOP RACE CONDITION!
|
||||
if ($self->TicketObj->Status() ne "Redacted Facilitator Email Sent") {
|
||||
if ($self->TicketObj->Status() ne "Re-send Facilitator Email") {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$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('Facilitator Email');
|
||||
|
||||
my $creator = "Davis Admin";
|
||||
@{ $self->{'To'} } = @To;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
# Custom Commit
|
||||
|
||||
#Move to Redacted Facilitator email sent.
|
||||
|
||||
my $ticket = $self->TicketObj;
|
||||
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
|
||||
|
||||
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$ticket->Comment(Content => 'AUTO Scrip #27: Email sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
|
||||
|
||||
#$ticket->Comment(Content => 'AUTO Scrip #27: Redacted Facilitator Email Sent');
|
||||
#my ($status, $msg) = $ticket->SetStatus('Redacted Facilitator Email Sent');
|
||||
|
||||
return 1;
|
||||
|
69
Scrip28.txt
Normal file
69
Scrip28.txt
Normal file
@ -0,0 +1,69 @@
|
||||
# Enhanced Send Facilitator Unredacted Email
|
||||
#
|
||||
#
|
||||
# Template - Demo Send Facilitators Full Email
|
||||
|
||||
# Custom Conditions:
|
||||
|
||||
# This script first checks for correct status
|
||||
# Then assembles email
|
||||
# Sends email
|
||||
|
||||
my $txn = $self->TransactionObj;
|
||||
my $type = $txn->Type;
|
||||
|
||||
return 0 unless $type eq "Status" || ( $type eq 'Set' && $txn->Field eq 'Status');
|
||||
return 0 unless $self->TicketObj->Status eq "Facilitator Accepted";
|
||||
return 1;
|
||||
|
||||
# Custom Preparation
|
||||
|
||||
require RT::Action::SendEmail;
|
||||
use strict;
|
||||
use vars qw/@ISA/;
|
||||
@ISA = qw(RT::Action::SendEmail);
|
||||
|
||||
#STOP RACE CONDITION!
|
||||
if ($self->TicketObj->Status() ne "Facilitator Accepted") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$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('Facilitator Email');
|
||||
|
||||
my $creator = "Davis Admin";
|
||||
@{ $self->{'To'} } = @To;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# Custom commit
|
||||
|
||||
# Move to Full Facilitator Email Sent and detailed email sent.
|
||||
|
||||
my $ticket = $self->TicketObj;
|
||||
my $facilitator = $ticket->FirstCustomFieldValue('Facilitator Email');
|
||||
|
||||
if ($ticket->FirstCustomFieldValue('Facilitator Email') eq '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$ticket->Comment(Content => 'AUTO Scrip #28: Email with all details sent. Facilitator is: '.$ticket->FirstCustomFieldValue('Facilitator Email'));
|
||||
|
||||
$ticket->Comment(Content => 'AUTO Scrip #28: Changing status to "Full Facilitator Email Sent"');
|
||||
my ($status, $msg) = $ticket->SetStatus('Full Facilitator Email Sent');
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
|
49
Scrip29.txt
Normal file
49
Scrip29.txt
Normal file
@ -0,0 +1,49 @@
|
||||
# On receiving email (On correspondence):
|
||||
# - Set Action Needed custom flag
|
||||
|
||||
# Custom condition:
|
||||
|
||||
return 0 unless $self->TransactionObj->Type eq "Correspond";
|
||||
return 0 unless $self->TicketObj->FirstCustomFieldValue('Action Needed') ne "Yes";
|
||||
|
||||
#$self->TicketObj->Comment(Content => 'AUTO Scrip #29 Setting Action Needed - Condition');
|
||||
|
||||
|
||||
|
||||
#return 0 unless $self->TicketObj->Transactions->Last eq 'Email';
|
||||
#return 0 unless $self->TicketObj->Transactions->Last->CreatorObj->Privileged;
|
||||
|
||||
1;
|
||||
|
||||
|
||||
# Custom action preparation code:
|
||||
|
||||
1;
|
||||
|
||||
|
||||
# Custom action commit code:
|
||||
|
||||
#Set custom flag on receiving external email
|
||||
|
||||
my $transaction = $self->TransactionObj;
|
||||
my $creator_id = $transaction->Creator;
|
||||
|
||||
# Get the Ticket object
|
||||
my $ticket = $self->TicketObj;
|
||||
|
||||
# Retrieve the most recent transaction (action)
|
||||
my $last_transaction = $ticket->Transactions->Last;
|
||||
|
||||
# Access the description of the last transaction
|
||||
my $last_transaction_description = $last_transaction->Description;
|
||||
|
||||
if ($last_transaction_description eq 'Outgoing email recorded by RT_System') {
|
||||
# $self->TicketObj->Comment(Content => 'AUTO Scrip #29 Setting Action Needed - Commit'.$last_transaction_description);
|
||||
} else {
|
||||
$self->TicketObj->AddCustomFieldValue(Field => 'Action Needed', Value => 'Yes');
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user