75 lines
2.0 KiB
Plaintext
75 lines
2.0 KiB
Plaintext
#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;
|
|
|